first of all, I'd suggest you to remove all of the quotes around the
mysql_connect($host, $user, $password) or die("could not connect!");
the same is to be done with the query itself.
Second, add an "or die" to the query:
mysql_query($insert) or die ("Unable to add user to the database:
This way you'll know what exactly _MySql_ says for an error if there
and third just tiny thing... it's not >? but ?> :-).
With best regards from Ukraine,
My blog: http://oire.org/menelion (mostly in Russian)
------------ Original message ------------
From: Nazish <naz...@gmail.com>
Date created: , 7:44:24 PM
Subject: [PHP] Submitting data to MySQL database using HTML/PHP form
I am creating a login page for my website. The users' information will be
stored in a MySQL database. I have a registration form on my home page, and
a separate file called "login.php" to process the user values. However, the
entries are not going to the MySQL database (however, the values can be
entered successfully using the command line).
I'd appreciate your insight on why the form entries are not making their way
to the MySQL database. Much thanks in advance!
This is the code for the form:
<form action='login.php' method='POST'>
Username: <input type='text' name='login'><br>
Password: <input type='password' name='password'><br>
<input type='submit' value='Submit'>
This is the code in login.php:
// Connect to server and select database.
$host = "localhost";
$user = "root";
$password = "abc";
$db = "directory";
mysql_connect("$host", "$user", "$password") or die("could not connect!");
mysql_select_db("$db") or die(mysql_error());
// username and password sent to table user_info in mysql
$login = $_POST['login'];
$password = $_POST['password'];
$insert = "INSERT INTO user_info
It's a simple form which I will develop further once the basic submission
process has been ironed out... Thanks again for any insight!
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php