PHP Drop Down List Insert -


i have php system user enter details form. once text fields entered inserts data database. however, have drop down lists not insert database. on matter moderate user , have not used php lot. thank you.

insertdetails.php  <div class="row">     <div class="label">adults 18+</div><!--end label-->     <div class="input">     <select name="adultspluseight" id="adultspluseight" class="detail" name="adultspluseight">        <option value="1">1</option>       <option value="2">2</option>       <option value="3">3</option>       <option value="4">4</option>       <option value="5">5</option>       <option value="6">6</option>       <option value="7">7</option>       <option value="8">8</option>       <option value="9">9</option>       <option value="10">10</option>              </select>     </div><!--end input-->      <div class="context"> choose how many people book maximum of 10 per booking</div><!--end context-->                   </div><!--end row-->   insert.php<?php $link = mysqli_connect("localhost", "root", "", "loginsystem"); // check connection if($link === false){ die("error: not connect. " . mysqli_connect_error()); } // escape user inputs security   $fname = mysqli_real_escape_string($link, $_post['firstname']);   $sname = mysqli_real_escape_string($link, $_post['lastname']);   $telnumb = mysqli_real_escape_string($link, $_post['telenumber']);   $custemail = mysqli_real_escape_string($link, $_post['email']);   $location = mysqli_real_escape_var_dump($link, $_post['wlocation']);   $adultplus = mysqli_real_escape_integer($link, $_post['adultspluseight']);   $childplus = mysqli_real_escape_integer($link, $_post['childrenplustwo']);   $addinfo = mysqli_real_escape_string($link, $_post['additinform']);  // attempt insert query execution   $sql = "insert customerdragon (fname, sname, telnumb, custemail,   $location , adultplus, childplus, addinfo) values ('$fname', '$sname', '$telnumb', '$custemail', '$location', '$adultplus', '$adultplus', '$childplus', '$addinfo',  )";  if(mysqli_query($link, $sql)){    echo "records added successfully."; } else{    echo "error: not able execute $sql. " . mysqli_error($link); } // close connection mysqli_close($link); ?>` 

that echo "error: not able execute $sql. " . mysqli_error($link); should have thrown sql error, didn't share us.

look @ in values

'$addinfo',           ^ 
  • remove trailing comma.

this error receive: notice: undefined index: wlocation in c:\xampp\htdocs\phploginsystem\insert1.php on line 14"

you have $ in $location column name:

$sql = "insert customerdragon (fname, sname, telnumb, custemail,  $location                                                                        ^ 
  • remove dollar sign. make sure column name indeed called "location".

remember $ in $location in column names (fname, sname, telnumb, custemail, $location , adultplus, childplus, addinfo)?

that needs read as:

(fname, sname, telnumb, custemail, custlocation, adultplus, childplus, addinfo) 

as per db schema.

edit:

also, you're repeating '$adultplus', '$adultplus', count miscount in data entry.

$sql = "insert customerdragon   (fname, sname, telnumb, custemail, custlocation, adultplus, childplus, addinfo)   values     ('$fname', '$sname', '$telnumb', '$custemail', '$location', '$adultplus', '$childplus', '$addinfo')"; 

add error reporting top of file(s) find errors.

<?php  error_reporting(e_all); ini_set('display_errors', 1);  // rest of code 

sidenote: error reporting should done in staging, , never production.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -