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>
I have a form that using to upload many datas and files. If a user uploaded a file, the file have to view from the same page while clicking view button and if any changes, have to update the same file. I have number of file uploads in one form.
My Form is...
<fieldset id="pan-step4-new" class="form-style">
<h2 class="fs-title">Please Upload Documents</h2>
<div class="black-underline" ></div>
<div class="col-md-4"><p>Your Passport Copy</p> </div>
<div class="col-md-4 col-xs-12 pan_new_pass_front_label">
<label class="btn btn-default btn-file btn-block" >
<h5 id="pan_new_pass_front_label">Attach Passport Front Page</h5>
<input type="file" name="pan_new_pass_front" id="pan_new_pass_front" accept="image/*" />
</label>
</div>
<div class="col-md-4 col-xs-12 input-group">
<label class="btn btn-default btn-file btn-block">
<h5 id="pan_new_pass_back_label">Attach Passport Address Page</h5>
<input type="file" name="pan_new_pass_back" id="pan_new_pass_back" accept="image/*" />
</label>
</div>
<div class="col-md-4"><p>Your Visa Page</p></div>
<div class="col-md-offset-4 col-md-4 col-xs-12 input-group">
<label class="btn btn-default btn-file btn-block">
<h5 id="pan_new_visa_label">Attach Visa Page</h5>
<input type="file" name="pan_new_visa" id="pan_new_visa" accept="image/*" />
</label>
</div>
<div class="col-md-4 "><p>Your Residency Proof in UAE</p></div>
<div class="col-md-offset-4 col-md-4 col-xs-12 input-group">
<label class="btn btn-default btn-file btn-block">
<h5 id="pan_new_proof_uae_label">Attach Proof Page</h5>
<input type="file" name="pan_new_proof_uae" id="pan_new_proof_uae" accept="image/*" />
</label>
</div>
<div class="col-md-4"><p>Your Photo</p></div>
<div class="col-md-offset-4 col-md-4 col-xs-12 input-group">
<label class="btn btn-default btn-file btn-block">
<h5 id="pan_new_photo_label">Attach Passport Size Photo</h5>
<input type="file" name="pan_new_photo" id="pan_new_photo" accept="image/*" />
</label>
</div>
<input type="button" class="btn btn-prev btn-style previous-button-style" value="prev" id="pan-step4-new-prev" />
<input type="submit" class="btn btn-next btn-style previous-button-style" name="pan_new_submit" value="submit" id="pan_new_submit"/>
</fieldset>
Use DropzoneJS.
It will preview your file before upload, and you can even remove the file before upload.
I have a to get a data from this form and insert it into database.
I am not able to find any solution online.
Everything works on the browser but the data is not getting stored into the table and echo inside the if block is not printed on screen.
The code is what can be seen below.
HTML
<form action="" method="POST">
<div class="container-fluid">
<div class="container">
<div class="row">
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-10 col-lg-4 col-md-offset-3" style="top:100px">
<div class="offer offer-radius offer-primary">
<div class="shape">
<div class="shape-text">
<span class="glyphicon glyphicon-user"></span>
</div>
</div>
<div class="offer-content">
<h4 style="margin-left:70px;font-size:20px">Enter your details below and enroll your slot</h4>
<div class="container col-xs-12">
<div class="stepwizard">
<div class="stepwizard-row setup-panel">
<div class="stepwizard-step">
<a href="#step-1" type="button" class="btn btn-primary btn-circle">
<i class="glyphicon glyphicon-user" style="margin-left: -18px;top: -24px;font-size: 90%;"></i></a>
</div>
<div class="stepwizard-step">
<a href="#step-2" type="button" class="btn btn-default btn-circle" disabled="disabled">
<i class="glyphicon glyphicon-education" style="margin-left: -18px;top: -24px;font-size: 90%;"></i></a>
</div>
<div class="stepwizard-step">
<a href="#step-4" type="button" class="btn btn-default btn-circle" disabled="disabled">
<i class="glyphicon glyphicon-ok" style="margin-left: -18px;top: -24px;font-size: 90%;"></i></a>
</div>
</div>
</div>
<div class="row setup-content" id="step-2">
<div class="col-xs-12">
<div class="col-md-10">
<h3>Qualification</h3>
<div class="col-xs-12 col-xs-offset-1" style="top:-50px">
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
</div>
<div class="col-xs-12" style="clear:both;top:-45px">
<input maxlength="20" type="text" required="required" class="form-control" placeholder="B Tech" readonly="" />
</div>
<div class="col-xs-12 form-group" style="clear:both;top:-40px">
<label for="subject">
Year of Pass out</label>
<input maxlength="20" type="text" required="required" class="form-control" placeholder="2016" readonly="" />
</div>
<div class="col-xs-12 form-group" style="clear:both;top:-40px">
<label for="subject">
Branch</label>
<select id="subject" name="subject" class="form-control" required="required">
<option value="na" selected="">Choose One:</option>
<option value="service">Computer Science</option>
<option value="suggestions">Information Technology</option>
<option value="product">Electronics & Communication</option>
<option value="product">Electronics & Electrical</option>
<option value="product">Instrumentation</option>
</select>
</div>
<div class="col-xs-12" style="clear:both;top:-40px">
<label for="subject">
Percentage (%)</label>
<input maxlength="6" type="text" class="form-control" placeholder="Your Percentage" name="percentage" />
</div>
</div>
</div>
</div>
</div>
<div class="row setup-content" id="step-1">
<div class="col-xs-12">
<div class="col-md-12">
<div class="container">
<div class="row">
<div class="col-xs-4">
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
<h3>Personal Information</h3>
<div class="col-xs-12" style="padding:15px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input maxlength="100" type="text" class="form-control" placeholder="First Name" name="F_Name" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input maxlength="100" type="text" class="form-control" placeholder="Last Name" name="L_Name" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope fa" aria-hidden="true"></i></span>
<input maxlength="100" type="text" class="form-control" placeholder="Your Email" name="EmailID" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone fa" aria-hidden="true"></i></span>
<input maxlength="14" type="text" class="form-control" placeholder="(+91) 555-555-5555" name="Phone_Number" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone fa" aria-hidden="true"></i></span>
<input maxlength="14" type="text" class="form-control" placeholder="Reference Code" name="R_Code" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row setup-content" id="step-4">
<div class="col-xs-12">
<div class="col-xs-12">
<div class="container" style="height:307px;">
<h4>Registered</h4>
<div class="col-xs-4" style="margin-left:-60px;top:60px">
<button class="btn btn-success completeBtn btn-lg pull-right" type="button" name="proceed">Proceed to payment</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
PHP
<?php
$cn= mysqli_connect('localhost','testuser','password','invoicedb');
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "string";
if(isset($_POST["proceed"]))
{echo "string";
$fname=$_POST['F_Name'];
$lname=$_POST['L_Name'];
$emailID=$_POST['EmailID'];
$phone_number=$_POST['Phone_Number'];
$reference_code=$_POST[‘R_Code’];
$branch=$_POST[‘subject’];
$percentage=$_POST[‘percentage’];
echo "insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')";
mysqli_query($cn,"insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')");
//best outside the if statement so user isn't stuck on a white blank page.
header("location:confirm.php");
exit;
}
?>
You can access $_POST[] values only if your form is submitted,
So, Replace this,
<button class="btn btn-success completeBtn btn-lg pull-right" type="button" name="proceed">Proceed to payment</button>
with This,
<button class="btn btn-success completeBtn btn-lg pull-right" type="submit" name="proceed">Proceed to payment</button>
It will work, without replacing your button with input.
If you are submitting the form in the same page then you should use -
<?php
$cn= mysqli_connect('localhost','testuser','password','invoicedb');
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "string";
if($_SERVER["REQUEST_METHOD"] == "POST")
{echo "string";
$fname=$_POST['F_Name'];
$lname=$_POST['L_Name'];
$emailID=$_POST['EmailID'];
$phone_number=$_POST['Phone_Number'];
$reference_code=$_POST[‘R_Code’];
$branch=$_POST[‘subject’];
$percentage=$_POST[‘percentage’];
echo "insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')";
mysqli_query($cn,"insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')");
//best outside the if statement so user isn't stuck on a white blank page.
header("location:confirm.php");
exit;
}
?>
if(isset($_POST["proceed"])){}
$_POST["proceed"] is not set at all, it needs a value in it to make sure it is set.
instead of checking if, just print the post values and try if your form is getting submitted.
inside php tag write below code and try echoing the data.
echo '<pre>';
print_r($_POST);
echo '----------------';
print_r($_REQUEST);
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
I have a list of product on mypage each product is having a enquiry button on it.
By clicking enquiry button bootstrap pop up opens.
I want that form to work for every product with product id of each product
I have achieved this by putting bootstrap pop up model in loop
my Question is. Instead of repeation blok of bootstrap pop up model , instead of keeping popup html in loop,is it possible to achieve this with function and keeping popup html outside loop ?
<?php if(isset($ser_gal)){
$gal_count =1;
foreach($ser_gal as $s){?>
<div class="element">
<div class="tz-inner" >
<div class="tz-image-item"> <img alt="" src="<?php echo URL;?>gallery/thumbs/thumb_<?php echo $s->IMAGE_PATH ; ?>"> </div>
<h6><?php echo $s->interior_cat;?></h6>
<hr />
<div class="cl"></div>
<?php echo $s->title;?>
<div align="center" >Enquiry</div>
</div>
</div>
<!--form-->
<div class="bs-example">
<div id="myModal<?php echo $gal_count;?>" class="modal fade">
<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">Enquiry</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="recipient-name" class="control-label">Name</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Email Id</label>
<input type="text" class="form-control texttrans_none" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Mobile No</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Product</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="message-text" class="control-label">Message</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!---->
<?php $gal_count++;} }?>