$_POST help?

I only get this

Notice: Undefined index: username in C:\Windows\xampp\htdocs\Create.php on line 54
Notice: Undefined index: password in C:\Windows\xampp\htdocs\Create.php on line 55
Notice: Undefined index: confirm in C:\Windows\xampp\htdocs\Create.php on line 56
Notice: Undefined index: submit in C:\Windows\xampp\htdocs\Create.php on line 57
Register


[php]

<?php include "Header.php"; echo "



"; $Username = $_POST['username']; $Password = $_POST['password']; $Confirm = $_POST['confirm']; $Submit = $_POST['submit']; if($Submit) { if (!$Username) { echo"
Please provide a username
"; } }[/php]
Register
Username:
Password:
Confirm Password:

You’re defining variables with nonexistent information.

$Username = $_POST[‘username’];
$Password = $_POST[‘password’];
$Confirm = $_POST[‘confirm’];
$Submit = $_POST[‘submit’];

won’t exist until after the submit button has been pressed. The php portion of the code should be
[php]
if(isset($_POST[‘submit’])) {

if (empty($_POST[‘username’])) {
echo"

Please provide a username
";
} else {
$Username = MySQL_real_escape_string($_POST[‘username’]);
}
if (empty($_POST[‘password’])) {
echo"
Please provide a valid password
";
} else {
$Password = md5($_POST[‘password’]); //assuming the password is encrypted
}
if (empty($_POST[‘confirm’])) {
echo"
Please confirm …
";
} else {
$Confirm = $_POST[‘confirm’];
}
}[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service