Hello Nazish,

Try to do the following in your login.php:

// assign your variables
echo "<br>$login<br>$password<br>$insert<br>";

                                 So we'll see the result.

With best regards from Ukraine,
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

------------ Original message ------------
From: Nazish <naz...@gmail.com>
To: php-general@lists.php.net
Date created: , 10:04:07 PM
Subject: [PHP] Submitting data to MySQL database using HTML/PHP form

      Thanks everyone! However, when I click the "submit" button, the url simply
moves to http://localhost/login.php (from home.php) and it is a blank page
(apart from asking whether it should remember the password for future use).
The values still do not move to the database.

I included most of your suggestions

a) added mysql _error()
b) different names for the variables
c) removed double quotes
d) changed ?> (silly error!)
e) modified the $insert query

The code now looks like this:


// Connect to server and select database.
$host = "localhost";
$user = "root";
$mysql_pass = "abc";
$db = "directory";

mysql_connect($host, $user, $mysql_pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

// username and password sent to mysql database

$login = $_POST['login'];
$password = $_POST['password'];

$insert = "INSERT INTO user_info
       (login, password)


or  die  ("Unable  to  add user to the database:".mysql_error());


I could insert the values using the command line, and it was updated in
MySQL, but it doesn't work through the form... it just goes to a blank page
on login.php. I'd appreciate any insights on why that's happening.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to