My HTML form is not submitting. I am trying to collect data from form to an API but the form is not submitting.
<div class="col-lg-12">
<div class="card">
<div class="panel panel-primary">
<div class="panel-header">
<h4 class="text-center">Investment Preview</h4>
</div>
<div class="panel-body">
<h5 class="text-center"> Credit your account </h5>
<?php $classObj->funding(); ?>
<form action="google.com" method="POST">
<p class="form-control-static text-center"> Enter amount in dollar </p>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="number" name="amount" min="300" max="4999" class="form-control" required />
</div>
</div>
<div class="panel-footer">
<button type="submit" name="fund" class="btn btn-primary btn-block btn-flat"> Invest </button>
</div>
</form>
</div>
</div>
</div>
This is the php code for funding method
function funding(){
echo "testing";
if(isset($_POST["fund"])) {
$amount = mysqli_real_escape_string($this->conn, trim($_POST['amount']));
echo $amount;
}
}
Its not submitting because you have your form action as google.com
<form action="google.com" method="POST">
This needs to be changed to the correct file path that contains the processing code.
This is form opening and closing are wrong please set like this after form submit done:
<div class="col-lg-12">
<div class="card">
<div class="panel panel-primary">
<div class="panel-header">
<h4 class="text-center">Investment Preview</h4>
</div>
<form action="https://www.google.com" method="POST">
<div class="panel-body">
<h5 class="text-center"> Credit your account </h5>
<?php $classObj->funding(); ?>
<p class="form-control-static text-center"> Enter amount in dollar </p>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="number" name="amount" min="300" max="4999" class="form-control" required />
</div>
</div>
<div class="panel-footer">
<button type="submit" name="fund" class="btn btn-primary btn-block btn-flat"> Invest </button>
</div>
</form>
</div>
</div>
Your HTML tags are not properly nested. The second </div> in the form matches the <div> before <form>, so it's ending the form as well. As a result, the submit button is not inside the form.
Move that </div> down, after </form>.
Any decent editor or IDE should have warned you about unbalanced tags. You also should have noticed that the button wasn't inside the form when you opened the browser's console and checked the DOM inspector.
<div class="col-lg-12">
<div class="card">
<div class="panel panel-primary">
<div class="panel-header">
<h4 class="text-center">Investment Preview</h4>
</div>
<div class="panel-body">
<h5 class="text-center"> Credit your account </h5>
<?php $classObj->funding(); ?>
<form action="yourscript.php" method="POST">
<p class="form-control-static text-center"> Enter amount in dollar </p>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="number" name="amount" min="300" max="4999" class="form-control" required />
</div>
<div class="panel-footer">
<button type="submit" name="fund" class="btn btn-primary btn-block btn-flat"> Invest </button>
</div>
</form>
</div>
</div>
</div>
</div>
Related
I'm using an "a" to call a modal:
ausencias.php
echo ' <i class="fa fa-pencil"></i>';
edit.php:
<html>
<?php
If(isset($_GET['aus'])) {
//BASE DE DADOS
include("connection.php");
$aprovar=$_GET['aus'];
$resultado=mysqli_query($db, "SELECT *
FROM contas as a, ausencia as h
WHERE a.id = h.id
AND h.idausensia='$aprovar'");
while($row = mysqli_fetch_array($resultado)){
$noome=$row['nome'];
$pic=$row['pic'];
$datasaida=$row['datasaida'];
$datavolta=$row['datavolta'];
$motivo=$row['tipos'];
$ficheiro=$row['justfile'];
}
?>
<div id="custom-content" class="modal-block modal-block-md">
<section class="panel">
<header class="panel-heading">
<h2 class="panel-title">Visualização de Pedido de Ausência - <?php echo($noome)?> </h2>
</header>
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<br>
<center><img class="img-responsive" src="<?php echo($pic) ?>" /></center>
<br>
</div>
<div class="col-md-22">
</div>
</div>
<div class="row">
<div class="col-md-40">
<div class="panel-body">
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Nome</label>
<div class="col-md-6">
<input type="text" value="<?php echo($noome) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Comprovativo</label>
<div class="col-md-6">
<a class="mb-xs mt-xs mr-xs btn btn-primary" href='download.php?down=<?php echo($ficheiro)?>'><i class="fa fa-cloud"></i> Baixar</a>
</div>
<br><br>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Motivo</label>
<div class="col-md-6">
<input type="text" value="<?php echo($motivo) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Inicio Ausência</label>
<div class="col-md-6">
<input type="text" value="<?php echo($datasaida) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Fim Ausência</label>
<div class="col-md-6">
<input type="text" value="<?php echo($datavolta) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<br>
<br>
<footer class="panel-footer">
<div class="row">
<div class="col-sm-9 col-sm-offset-3">
<form action="" method="post">
<input type="submit" value="Test" name="confirmar">
<button class="btn btn-default modal-dismiss">Sair</button>
<button name="recusar" type="button" class="mb-xs mt-xs mr-xs btn btn-danger">Recusar</button>
</form>
</div>
</div>
</footer>
</div>
</div>
</div>
</div>
<?php
if(isset($_POST['confirmar'])){
mysqli_query($db, "UPDATE ausencia SET estados='Rascunho' WHERE idausensia='$aprovar'");
mysqli_close($db);
header("Location: ausencias.php");
}
?>
<footer class="panel-footer">
<div class="row">
<div class="col-md-12 text-right">
</div>
</div>
</footer>
</section>
</div>
<?php }?>
<html>
But for some reason, the Isset is not working for the button, but when i remove the If, the SQL statement works. When i click the button it just close the modal and don't trigger what is inside the If.
Can anyone help me?
the if that dont work is that:
if(isset($_POST['confirmar'])){
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
you are adding direct php file in href of anchor it will redirect you on target page use Simply Modal window of Bootstrap.
I have the following code:
<section id="about" class="home-section color-dark bg-white">
<form id="contact-form" class="wow bounceInUp" data-wow-offset="10" data-wow-delay="0.2s" action="load_event.php" method="post">
<div class="container marginbot-50">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="wow flipInY" data-wow-offset="0" data-wow-delay="0.4s">
<div class="section-heading text-center">
<h4 class="h-bold">Encuentra un evento</h4>
<input type="text" class="form-control input-lg" required placeholder="ID del evento" oninvalid="this.setCustomValidity('Este campo es requerido')" id="event_id" name="event_id"></input>
<input type="submit" class="btn btn-skin btn-lg btn-block" value="Buscar" ></input>
</div>
</div>
</div>
</div>
</div>
</form>
</section>
but the required validation on the text input tag works only the first time, if I click on the submit button the first time with the text field empty, the following attempts will say that the field is empty even if it is not. This behavior is the same on Firefox and Internet Explorer. Any ideas?
I need to save data of a form into database..It is simple for me with a submit button..But now here I need to save data at its different stages..Or I'm having different tabs for each stage.. How could I save data.? I'm using a next button in order to navigate from one tab to other and at last there is a submit button..How it is possible to save data while clicking the next button.?
Here is my form:
<div class="stepwizard col-md-offset-3">
<div class="stepwizard-row setup-panel">
<div class="stepwizard-step">
1
<p>Step 1</p>
</div>
<div class="stepwizard-step">
2
<p>Step 2</p>
</div>
<div class="stepwizard-step">
3
<p>Step 3</p>
</div>
</div>
</div>
<?php
$this->load->helper('form');
$attributes=array('method'=>'post','id'=>'myform','class'=>'form-horizontal','role'=>'form');
echo form_open("form_controller/insert",$attributes);
?>
<div class="row setup-content" id="step-1">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 1</h3>
<div class="form-group">
<label class="control-label">Name</label>
<input type="text" required="required" class="form-control" />
</div>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-2">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 2</h3>
<div class="form-group">
<label class="control-label">Age</label>
<input maxlength="200" type="text" required="required" class="form-control" />
</div>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-3">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 3</h3>
<div class="form-group">
<label class="control-label">Location</label>
<input maxlength="200" type="text" required="required" class="form-control" />
</div>
<button class="btn btn-success btn-lg pull-right" type="submit">Submit</button>
</div>
</div>
</div>
<?php echo form_close(); ?>
There are several ways of creating multi step forms. Here are some of the useful posts:
How to Create a Multi-Step Form Using RhinoSlider
session-based PHP-multistep-form with mvc-pattern
Multi step/page form in PHP & CodeIgniter
Multiple step form ragistration in codeigniter
Multi-Step Forms and Data Submission in CodeIgniter
The button for some reason does not work, it just refreshes the page.
Could someone please provide some information?
I am new to bootstrap.
The button 'Sign in' is supposed to send action to $_POST['submit']) and proceed the login function.
The form data must be sent to the same page.
<?php
if(isLoggedIn()) { redirect(); }
// Login Process
if(check_value($_POST['submit'])) {
$userLogin = new login();
$userLogin->validateLogin($_POST['employee_number'], $_POST['password']);
}
?>
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<small>Sign in</small>
</h3>
</div>
<div class="panel-body">
<form action="" method="post">
<div class="row">
<div class="col-xs-7 col-sm-7 col-md-7">
<div class="form-group">
<input type="text" name="employee_number" class="form-control input-sm" placeholder="Employee number">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-7 col-sm-7 col-md-7">
<div class="form-group">
<input type="password" name="password" class="form-control input-sm" placeholder="Password">
</div>
</div>
</div>
<div class="form-group last">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-success btn-sm" id="submit">Sign in</button>
<button type="reset" class="btn btn-default btn-sm">Reset</button>
</div>
</div>
</form>
</div>
</div>
</div>
/**
* check_value
* Looks for valid value and setted ones.
*/
function check_value($value) {
if((#count($value)>0 and !#empty($value) and #isset($value)) || $value=='0') {
return true;
}
}
You need to provide action to form.
Right now it will just reload current page - if you provide url there, it will send form to that url (and user will be redirected there).
I want to submit data in database using bootstrap modal popup but when i press submit buttons nothing happens and i think that page which is used to submit a record is also not called. Below is the code of modal popup: i have called addProducts.php page but it is not called on click of a submit buttom please help to solve it. Thanks..
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add Products Details</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<form role="form" name="Insertdb" method="post" action="Insert_code/add-products.php">
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Name</label>
</div>
</div>
<div class="col-lg-6">
<input class="form-control" name="prodName" placeholder="Enter product Name">
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Price</label>
</div>
</div>
<div class="col-lg-6">
<input class="form-control" name="prodPrice" placeholder="Enter product price">
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Type</label>
</div>
</div>
<div class="col-lg-6">
<input class="form-control" name="productType" placeholder="Enter product type">
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Description</label>
</div>
</div>
<div class="col-lg-6">
<textarea class="form-control" name="productDesc" rows="3"></textarea>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input name="button1" type="submit" class="btn btn-primary">
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
</div>
<?
require_once('user.inc.php');
$Users = new Users();
$name=$_REQUEST['prodName'];
$price=$_REQUEST['prodPrice'];
$type=$_REQUEST['productType'];
$description=$_REQUEST['productDesc'];
$query="INSERT INTO tbl_product(`product_name`,`product_desc`,`product_price`,`product_type`)
VALUES('".$name."','".$description."','".$price."','".$type."')";
if(!executeQuery($query))
{
echo '<script language="javascript">';
echo 'alert("An error occured. Please try again")';
echo '</script>';
else
{
echo '<script language="javascript">';
echo 'alert("Record Successfully Inserted")';
echo '</script>';
}
?>