I have very little knowledge of PHP, I have been trying to cobble up a small form to insert a text value into a specific field in a specific row in a table in a database.
This is the form code:
- Code: Select all
<HTML>
<form action="script.php" method="post"/>
<p>Input Name: <input type="text" name="name"</p>
//name already exists in the table
<p>Input Code: <input type="text" name="code"</p>
//need to add this value to a field called code only for that name
<input type="submit" value="Submit" />
</form>
</HTML>
This is the PHP Script:
- Code: Select all
<?php
$name = $_POST['name'];
$jobs = $_POST['code'];
echo "Refer to list of Profession ID's and enter details accordingly";
mysql_connect ("localhost", "root", "") or die ('Error: ' . mysql_error());
mysql_select_db ("office_db");
$query="INSERT INTO personal WHERE name='".$name."' (code) VALUES ('".$code."');
mysql_query($query) or die ('Error updating databse');
echo "Database Updated";
?>
I understand this is a very basic syntax error, and I am not knowledgeable about it at all. Kindly help me with this and I shall be very grateful. Thank you.


