Hi, I recently created a mysql database using phpmyadmin. I then proceeded to make a form to insert data into the database, but the problem is that the form is only able to insert one record, and then if I try inserting another record, the new one is not seen in the database. There is no error messages seen in the form when entering a new record.
Heres the code for the form
[code=html]
<html>
<head>
</head>
<center>
<form method="post" action="script. php">
<input type="hidden" name="id" value="null">
<table>
<tr><td align="left">Na me</td>
<td><input type="text" name="name"></td>
</tr>
<tr><td align="left">Te lephone</td>
<td><input type="text" name="telephone " size="20"></td>
</tr>
<tr><td align="left">Bi rthday</td>
<td><input type="text" name="birthday" size="20"></td>
</tr>
<tr><td colspan="2">
<p align="center">
<input type="submit" value="Enter record">
</td>
</tr>
</table>
</form>
</center>
</html>
[/code]
And Heres the code for the php script
[code=php]
<?
$DBhost = "localhost" ;
$DBuser = "username";
$DBpass = "password";
$DBName = "database name";
$table = "table name";
mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to database");
@mysql_select_d b("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$id','$ name','$telepho ne','$birthday' )";
$results = mysql_query($sq lquery);
mysql_close();
print "<html><body><c enter>";
print "<p>You have just entered this record<p>";
print "Name : $name<br>";
print "Telephone : $telephone<br>" ;
print "Birthday :$birthday";
print "</body></html>";
?>[/code]
Heres the code for the form
[code=html]
<html>
<head>
</head>
<center>
<form method="post" action="script. php">
<input type="hidden" name="id" value="null">
<table>
<tr><td align="left">Na me</td>
<td><input type="text" name="name"></td>
</tr>
<tr><td align="left">Te lephone</td>
<td><input type="text" name="telephone " size="20"></td>
</tr>
<tr><td align="left">Bi rthday</td>
<td><input type="text" name="birthday" size="20"></td>
</tr>
<tr><td colspan="2">
<p align="center">
<input type="submit" value="Enter record">
</td>
</tr>
</table>
</form>
</center>
</html>
[/code]
And Heres the code for the php script
[code=php]
<?
$DBhost = "localhost" ;
$DBuser = "username";
$DBpass = "password";
$DBName = "database name";
$table = "table name";
mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to database");
@mysql_select_d b("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$id','$ name','$telepho ne','$birthday' )";
$results = mysql_query($sq lquery);
mysql_close();
print "<html><body><c enter>";
print "<p>You have just entered this record<p>";
print "Name : $name<br>";
print "Telephone : $telephone<br>" ;
print "Birthday :$birthday";
print "</body></html>";
?>[/code]
Comment