Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing form data with PHP to MySQL database
    primarykey
    data
    text
    <p>I am unable to pass the following form data: </p> <pre><code>&lt;form method="post" action="form.php" id="contact" enctype="multipart/form-data"&gt; &lt;fieldset&gt; &lt;legend&gt;Contact Us&lt;/legend&gt; &lt;div id="conleft"&gt; &lt;label&gt;First Name:&lt;/label&gt;&lt;input type="text" name="firstName" required /&gt; &lt;label&gt;Last Name:&lt;/label&gt;&lt;input type="text" name="lastName" required /&gt; &lt;label&gt;House/Flat No:&lt;/label&gt;&lt;input type="text" name="houseNum" /&gt; &lt;label&gt;Address:&lt;/label&gt;&lt;input type="text" name="address" /&gt; &lt;label&gt;Town/City:&lt;/label&gt; &lt;input type="text" name="city" /&gt; &lt;label&gt;Postcode:&lt;/label&gt; &lt;input type="text" name="postcode" /&gt; &lt;label&gt;Telephone:&lt;/label&gt; &lt;input type="tel" name="telephone" /&gt; &lt;label&gt;Email:&lt;/label&gt; &lt;input type="email" name="email" required /&gt; &lt;/div&gt; &lt;div id="conright"&gt; &lt;label&gt;Enquiry:&lt;/label&gt;&lt;textarea name="description" rows="13" required &gt;&lt;/textarea&gt; &lt;label&gt;Date:&lt;/label&gt;&lt;input type="month" name="date" /&gt;&lt;br /&gt;&lt;br /&gt; &lt;input type="submit" name="submit" value="Send" /&gt; &lt;input type="reset" name="Reset" value="Reset" /&gt; &lt;input type="hidden" name="customerNo" /&gt; &lt;input type="hidden" name="enquiryNo" /&gt; &lt;input type="radio" name="type" value="customer" checked /&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>with the following PHP to MySQL database</p> <pre><code>&lt;?php $con=mysqli_connect("localhost", "root", "myuser","mypass"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql1="INSERT INTO customers (NULL, firstName, lastName, houseNum, address, city, postcode, telephone, email, type) VALUES ('$_POST[customerNo]','$_POST[firstName]','$_POST[lastName]','$_POST[houseNum]','$_POST[address]','$_POST[city]','$_POST[telephone]', '$_POST[postcode]''$_POST[email]','$_POST[type]')"; mysqli_query($con,$sql1); $sql2="INSERT INTO enquiry (NULL, customerNo, description, date) VALUES ('$_POST[enquiryNo]','$_POST[customerNo]','$_POST[description]','$_POST[lastName]','$_POST[date]')"; mysqli_query($con,$sql2); echo "&lt;script language=javascript&gt;window.location = 'thanks.html';&lt;/script&gt;"; mysqli_close($con); ?&gt; </code></pre> <p>The web page acts as if the form data has been sent by showing the thank.html page when submitted, but no data is populated in the database. I've set AUTO INCREMENT, PRIMARY and FOREIGN keys, is it the way I am trying to the pass the values?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload