PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$DBhost ="localhost"; //mysql-server
$DBuser = "root"; //mysqluser
$DBpass = "123";
$DBName = "learnphp";
$table = "information";
mysql_connect($DBhost,$DBuser,$DBpass) or die("error");
mysql_select_db("$DBName") or die("error");
$sqlquery = "INSERT INTO $table (id,name,email,opinion)VALUES ('$_POST[id]','$_POST[name]','$_POST[email]','$_POST[opinion]')";
$results=mysql_query($sqlquery);mysql_close();
echo "<html><titile>PHP and mysql</title><body><p><center>you just enter this information into the database<p><blockquote>";
print "Name:$_POST[name]<p>E-mail:$_POST[email]<p>opinion:$_POST[opinion]</blockquote></center>";
$results=mysql_query($sqlquery) or die(mysql_error());
There are some issues - your $_POST['id'] is set to "NULL" as a string (not NULL value). So there might be data type mismatch error if your MySQL id field is of INT.
If id field is supposed to be a primary key in your table then set this to auto_increment in the table strcuture and drop this field from your SQL statement (and also from your HTML form). MySQL server will add this to the row.
$results=mysql_query($sqlquery) or die(mysql_error());
There are some issues - your $_POST['id'] is set to "NULL" as a string (not NULL value). So there might be data type data type mismatch error if your MySQL id field is of INT.
If id field is supposed to be a primary key in your table then set this to auto_increment in the table strcuture and drop this field from your SQL statement (and also from your HTML form). MySQL server will add this to the row.