hi all basically i'm making a php and sql registration form?
and i'm getting this error $p2 = $_POST['p2'];
my code is this
i have tried and tried to search the error but can't find any answers to it
and i'm getting this error $p2 = $_POST['p2'];
my code is this
PHP:
<?php
$error = NULL;
if(isset($_POST['submit'])){
//Get form data
$u = $_POST['u'];
$p = $_POST['p'];
$p2 = $_POST['p2'];
$e = $_POST['e'];
if(strlen($u) < 5){
$error = "<p>Your username must be at least 5 characters</p>";
}elseif($p2 != $p){
$error .= "<p>Your passwords do not match</p>";
}else{
//Form is valid
//Connect to the database
$mysqli = NEW MYSQLi('localhost','root','','profiles');
//Sanitize form data
$u = $mysqli->real_escape_string($u);
$p = $mysqli->real_escape_string($p);
$p2 = $mysqli->real_escape_string($p2);
$e = $mysqli->real_escape_string($e);
//Generate Vkey
$vkey = md5(time().$u);
//insert account into the database
$p = md5($p);
$insert = $mysqli->query("INSERT INTO accounts(usname,password,email,vkey)
VALUES('$u','$p','$e','$vkey')");
if($insert){
echo "Success";
}else{
}
}
}
?>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form method="POST" action="">
<table border="0" align="center" cellpadding="5">
<tr>
<td align="right">Username:</td>
<td><input type="TEXT" name="u" required/></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="PASSWORD" name="p" required/></td>
</tr>
<tr>
<td align="right">Repeat Password:</td>
<td><input type="REPEATPASSWORD" name="r" required/></td>
</tr>
<tr>
<td align="right">Email Address:</td>
<td><input type="EMAIL" name="e" required/></td>
</tr>
<tr>
<tr>
<td colspan="2" align="center"><input type="SUBMIT" name="submit" value="Register" required/></td>
</tr>
</table>
</form>
<center>
<?php
$error = NULL;
?>
</center>
</body>
</html>
i have tried and tried to search the error but can't find any answers to it