Note that there are some explanatory texts on larger screens.

plurals
  1. POForm Action's PHP file not working
    primarykey
    data
    text
    <p>I have a simple form that's supposed to enter submissions in a MySQL database but whenever the form is submitted I get a server 500 error. I'm new to the PHP/MySQL so i'm not seeing the problem. Any ideas?</p> <p><strong>HTML Form Excerpt:</strong></p> <pre><code>&lt;form method="post" action="submit.php"&gt; &lt;label for="fname"&gt;First Name *:&lt;/label&gt; &lt;input type="text" id="fname" name="fname" /&gt;&lt;br /&gt; &lt;label for="lname"&gt;Last Name *:&lt;/label&gt; &lt;input type="text" id="lname" name="lname" /&gt;&lt;br /&gt; &lt;label for="email"&gt;Email *:&lt;/label&gt; &lt;input type="email" id="email" name="email" /&gt;&lt;br /&gt; &lt;label for="phone"&gt;Phone Number:&lt;/label&gt; &lt;input type="tel" id="phone" name="phone" /&gt;&lt;br /&gt; &lt;input type="checkbox" id="ageverify" /&gt; &lt;label for="ageverify"&gt;I am at least 18 years of age *&lt;/label&gt;&lt;br /&gt; &lt;input type="checkbox" id="terms" /&gt; &lt;label for="terms"&gt;I agree to the Terms &amp;amp; Conditions *&lt;/label&gt;&lt;br /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p><strong>Entirety of submit.php</strong></p> <pre><code>&lt;? mysql_connect("localhost","USERNAME","PASSWORD"); mysql_select_db("DB_NAME"); $sql = "INSERT into entries (fname,lname,email,phone,ageverify,terms) "; $sql .= "VALUES ("; $sql .= $_POST['fname'] . ',' . $_POST['lname'] . ',' . $_POST['email'] . ','; $sql .= $_POST['phone']; if (isset($_POST['ageverify']) // if checked will exist, otherwise it won't $sql .= 'yes' . ','; else $sql .= 'no' . ','; if (isset($_POST['terms']) $sql .= 'yes' . ','; else $sql .= 'no' . ','; $sql .= ')'; $result = mysql_query($sql); if($result){ echo("Thanks"); } else{ echo("Something went wrong"); } ?&gt; </code></pre> <hr> <p><strong>UPDATE: WORKING CODE (As rudimentary as it may be)</strong></p> <pre><code>&lt;?php mysql_connect("localhost","USERNAME","PASSWORD"); mysql_select_db("DB_NAME"); $sql = "INSERT into entries (fname,lname,email,phone,ageverify,terms) "; $sql .= "VALUES ("; $sql .= '"' . $_POST['fname'] . '"' . ',' . '"' . $_POST['lname'] . '"' . ',' . '"' . $_POST['email'] . '"' . ','; $sql .= '"' . $_POST['phone'] . '"'; if (isset($_POST['ageverify'])) // if checked will exist, otherwise it won't $sql .= ',' . '"yes"' ; else $sql .= ',' . '"no"'; if (isset($_POST['terms'])) $sql .= ',' . '"yes"'; else $sql .= ',' . '"no"'; $sql .= ')'; echo $sql; $result = mysql_query($sql); if($result){ echo("Thanks"); } else{ echo("Something went wrong"); } ?&gt; </code></pre>
    singulars
    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