php - Using arrays in registration form but values in the form not submitted -
i have form this:
<form class="registration-form" name="applicationform" action="<?=$_server['php_self']?>" method="get"> <div class="form-top"><h3 class="col-md-12 col-md-offset-4">application employment</h3> </div> <div class="col-md-12 col-sm-12 col-lg-6"> <div class="col-md-12"> <div class="form-group"> <label for="inputfirstname">first name</label> <input type="text" class="form-control required" id="inputfirstname" placeholder="first name" name="driver[first_name]" /> </div> <div class="form-group"> <label for="inputmiddle">middle initial</label> <input type="text" class="form-control" id="inputmiddle" placeholder="middle initial" name="driver[middle]" /> </div> <div class="form-group"> <label for="inputlastname">last name</label> <input type="email" class="form-control required" id="inputlastname" placeholder="last name" name="driver[last_name]" /> </div> <div class="form-group"> <label for="inputdob">date of birth</label> <input type="email" class="form-control required datepicker" id="inputdob" placeholder="mm/dd/yyyy" name="driver[dob]" /> </div> however when try display values after hitting submit button, won't submit , won't display values. have displaying values:
$form_names = array_keys($_get); $form_values = array_values($_get); if(isset($_get["submit"])) { echo "<h3>your input:</h3>"; ($i = 0; $i < sizeof($_get); $i++) { echo "<p>".$form_names[$i]." = " . $form_values[$i] . "</p>"; } } kindly tell me missing or wrong in code because won't submit , display values. doesn't send email after registration.
there many errors in posted code.
firstly, if code not have closing </form> tag, need add it.
you have no name attribute set if(isset($_get["submit"])) such submit button bearing matching name attribute, therefore nothing inside conditional statement fire up.
<input type = "submit" name = "submit" value = "submit"> you need add driver attribute $_get arrays.
$form_names = array_keys($_get['driver']); $form_values = array_values($_get['driver']); and in loop also:
for ($i = 0; $i < sizeof($_get['driver']); $i++) plus, both last name , date of birth inputs using <input type="email" instead of text , date respectively.
had tried enter data email input , way have now, have failed , same date input.
"it doesn't send email after registration."
i don't see mailing function in posted code, therefore need sort out.
consult manual on mail() if using:
- if php mail: http://php.net/manual/en/function.mail.php
- if phpmailer: https://github.com/phpmailer/phpmailer
- if swift mailer: http://swiftmailer.org/
add error reporting top of file(s) find errors.
<?php error_reporting(e_all); ini_set('display_errors', 1); // rest of code sidenote: displaying errors should done in staging, , never production.
footnotes:
i suggest not use post, since seems may sending sensitive information (via web). using post safer.
therefore, can change instances of $_get $_post including form method , same results.
sample results answer:
first_name = john middle = q last_name = public dob = 01/01/1984
Comments
Post a Comment