I am new to both HTML and PHP. I am trying to learn how to get my first simple data base going and am stumped at inserting data into MySQL from an HTML form.
I have been using the tutorial:
http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?tw=programming
I have never gotten data to post, and got sidetracked into modularizing the scripts by putting different functions into different pages to keep things organized. The form does call the add record, but it doesn't update. Plus I am now getting a weird error and I cannot see where the syntax error is. Even when I wasn't getting the systax error, it would not add the record. I have tried about 30 different variations, none of which as worked. I have read a dozen strings on the subject here, but none have gotten me past this roadblock. I have to call for help.
I am using FoxServ 3.0. I believe I have
PHP Version 4.2.2, MySQL 1.3 on a W98-SE box.
the error I am currently getting is:
Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in C:\FoxServ\www\Input_Add_test.php on line 31
Line 31 is this line in Add_Test.php
$sql = "INSERT INTO $Dbs (first,last,address,position) VALUES ('$Post['first']','$Post['last']','$Post['address']','$Post['position']')";
$result = mysql_query($sql);
Here are the two PHP scripts:
Input_Test.php
<html>
<head>
<title>Input_Test</title>
</head>
<body>
<form ACTION="Add_Test.php" NAME="Add_Test" method="post" >
<table border="2">
<tr><td>First name:</td><td><input type="Text" name="first"></td></tr>
<tr><td>Last name:</td><td><input type="Text" name="last"></td></tr>
<tr><td>Address:</td><td><input type="Text" name="address"></td></tr>
<tr><td>Position:</td><td><input type="Text" name="position"></td></tr>
<tr><td> </td><td align="center"><input type="Submit" name="submit" value="Enter information"></td></tr>
</table>
</form>
</body>
</html>
Add_Test.php
<HTML>
<HEAD>
<TITLE>Add_Test</TITLE>
</HEAD>
<BODY>
<?PHP
Echo "insert"
$sql = "INSERT INTO $Dbs (first,last,address,position) VALUES ('$Post['first']','$Post['last']','$Post['address']','$Post['position']')";
$result = mysql_query($sql);
?>
</BODY>
</HTML>
Thanks in advance,
Mike