Submitting data to MySQL database using HTML/PHP form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

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'>
</form>

This is the code in login.php:

<?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
                (login, password)
                VALUES
                ("$login",
                "$password");
mysql_query($insert);

>?

It's a simple form which I will develop further once the basic submission
process has been ironed out... Thanks again for any insight!

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux