So I'm trying to create a simple sign up the program that inserts the data into a MySQL database:
<?php
$first=$_POST['name'];
$last=$_POST['lname'];
$uname=$_POST['uname'];
$pass=$_POST['pass'];
if(empty($first) || empty($last) || empty($uname) || empty($pass))
{
header('Location: redirect.php');
}
else
{
$conn=new mysqli("localhost", "root", "", "login");
if($conn->connect_error)
{
die("We've lost the connection because of ".$conn->connect_error);
}
$insert="INSERT INTO people (name, lastname, username, pass) VALUES ('$name', '$last', '$uname', '$pass')";
$conn->query($insert);
}
?>
However when i run the program and insert the data I get the error:
Notice: Undefined variable: name in C:\xampp\htdocs\vtor\sign_up.php on line 27
line 27 is this line:
$insert="INSERT INTO people (name, lastname, username, pass) VALUES
('$name', '$last', '$uname', '$pass')";
Any ideas?