I have created a webpage named Register.php which should insert data into my database. The problem with this is that the registration page works but then when I try to log in the information was not added into my database is there anything that I did wrong that I cannot find?
<?php
echo "<h1>Register</h1>";
$submit = $_POST['submit'];
//form data
$FullName = strip_tags($_POST['FullName']);
$UserName = strip_tags($_POST['UserName']);
$Password = strip_tags($_POST['Password']);
$RepeatPassword = strip_tags($_POST['RepeatPassword']);
if ($submit)
{
//open database
$connect = mysql_connect("localhost","root","");
mysql_select_db("cs266db_db1");
$namecheck = mysql_query("SELECT UserName FROM user_ID WHERE UserName='$UserName'");
$count = mysql_num_rows($namecheck);
if ($count!=0)
{
die("UserName already taken");
}
//check for existence
if($FullName&&$UserName&&$Password&&$RepeatPassword)
{
//check password and repeat password match
if($Password==$RepeatPassword)
{
//check length of username and fullname
if (strlen($UserName) > 25 || strlen($FullName)>25)
{
echo "Length of username or fullname is over 25 characters!";
}
else {
//check password
if(strlen($Password)>25 || strlen($Password) < 6) {
echo "Password must be between 6 and 25 characters";
} else {
//encrypt password
$Password = md5($Password);
$RepeatPassword = md5($RepeatPassword);
$queryreg = mysql_query("INSERT INTO user_id VALUES (FullName='".$FullName."',UserName='".$UserName."',Password='".$Password."'");
}
die("You have been registered <a href='index1.php'> Return to Login Page </a>");
}
}
else{
echo "Your passwords do not match";
}
} else {
echo "Please fill in all fields!";
}
}
?>
<html>
<form action="register.php" method="POST">
<table>
<tr>
<td>
Your full name:
</td>
<td>
<input type="text" name="FullName" value="<?php echo $FullName ?>">
</td>
</tr>
<tr>
<td>
Choose a username:
</td>
<td>
<input type="text" name="UserName" value="<?php echo $UserName ?>">
</td>
</tr>
<tr>
<td>
Choose a password:
</td>
<td>
<input type="password" name="Password">
</td>
</tr>
<tr>
<td>
Repeat your password:
</td>
<td>
<input type="password" name="RepeatPassword">
</td>
</tr>
</table>
<br>
<input type="submit" name="submit" value="Register">
</form>
</html>
Im getting an error of this as well(I am running on netbeans):
Notice: Undefined index: submit in C:\Xampp\htdocs\Resume_DB\register.php on line 4 Notice: Undefined index: FullName in C:\Xampp\htdocs\Resume_DB\register.php on line 7 Notice: Undefined index: UserName in C:\Xampp\htdocs\Resume_DB\register.php on line 8 Notice: Undefined index: Password in C:\Xampp\htdocs\Resume_DB\register.php on line 9 Notice: Undefined index: RepeatPassword in C:\Xampp\htdocs\Resume_DB\register.php on line 10
Does this have to do with my problem of insertion? If so can you help! Please and thank you!