Can you correct this php registration script for me?

Hi everyone. I’m having a bit of trouble with my registration script. When I go to my action.php file, I get these error:

Notice: Undefined index: uname1 in C:\xampp\htdocs\series\action.php on line 2

Notice: Undefined index: pword1 in C:\xampp\htdocs\series\action.php on line 3

But, When I test my script, Everything works fine.
I don’t understand what’s going on.

These are my two files:
[php]index.php:

Username:

Password:

[/php]

action.php:
[php]<?php
$username_1 = $_POST[‘uname1’];
$password_1 = $_POST[‘pword1’];
$con = mysql_connect(“localhost”, “root”, “”);
if (!$con)
{
die('Could not connect: '. mysql_error());
}

mysql_select_db(“user1”, $con);

mysql_query(“INSERT INTO userlogin (username, password)
VALUES (’$username_1’, ‘$password_1’)”);

mysql_close($con);
?>[/php]

I appreciate any help that anyone can offer!

That just means that php is seeing the variables before there’s anything assigned to them. Once its live, they should go away. For now, just use if(isset()) to get rid of them, or try $username_1 = @$_POST[‘uname1’];

Sponsor our Newsletter | Privacy Policy | Terms of Service