I’m probably missing something basic, so at this point, I just need a second pair of eyes. I’m constructing a simple input form on my website so that visitors can submit some information. Right now, im just calling them jobs (i just want to get it working). When I click submit, I am not seeing any information on the PHPMYadmin side, so the SQL database is obviously not being updated. My bad for not saying this the first time.
ALSO, my password is hidden, for security reasons, but it is correct.
Here is my PHP and my HTML.
<?php
$con = mysql_connect("localhost","projedl8_Jason","/////");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("projedl8_quicktern", $con);
$sql="INSERT INTO jobListForm (NAME, Email, JobTitle, JobDescription)
VALUES ('JASON', '$_POST[email]','$_POST[job_title]','$_POST[job_description]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
And lastly:
<form name="submitjobform" method="post" action="job_submit.php">
<table width="450px">
<tr>
<td valign="top">
<label for="name">Name</label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="100" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="job_title">Job Title</label>
</td>
<td valign="top">
<input type="text" name="job_title" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments">Job Description</label>
</td>
<td valign="top">
<textarea name="job_description" maxlength="1000" cols="25" rows="6"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:left">
<input type="submit" name="submit" value="Submit" size="100"></td>
</tr>
</table>
</form>
Here is the screen shot for PHPMYADMIN
I think it might be the missing single quotes inside
$_POST[...].However your solution is open to SQL injection, so better use prepared statements,
that handle quotes/backslashes, escaping in the parameters.
(The four ssss indicate that every parameter is a string.)