Hello experts I would be very happy about your help
The aim of the code is that the user can register.
So it should store the values of form id=”signup”
should be stored in the mysql database.
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Mahlzeit</title>
<link rel="stylesheet" href="./Login.css">
</head>
<!DOCTYPE html>
<html>
<head>
<title>Slide Navbar</title>
<link rel="stylesheet" type="text/css" href="slide navbar Login.css">
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<div class="main">
<input type="checkbox" id="chk" aria-hidden="true">
<div class="signup">
<form action="http://localhost/Kulinarik/signup_save.php" methode="POST" id="signup">
<label for="chk" aria-hidden="true">Sign up</label>
<input type="text" name="vorname" placeholder="Vorname" id="vorname">
<input type="text" name="nachname" placeholder="Nachname" id="nachname">
<input type="email" name="email" placeholder="Email" id="email">
<button type="submit" value="signup">Sign up</button>
</form>
</div>
<div class="login">
<form action="login_save.php" methode="POST" id="login">
<label for="chk" aria-hidden="true">Login</label>
<input type="email" name="email" placeholder="Email" required=""/>
<input type="password" name="pswd" placeholder="Password" required=""/>
<button type="submit" value="Login">Login</button>
<a class="changepassword">Passwort ändern</a>
</form>
</div>
</input>
</div>
</body>
</html>
</body>
</html>
and the connection
<?php
session_start();
?>
<?php
$con= mysqli_connect('localhost','root','123456', 'userdata',);
$email = $_POST['email'];
$vorname = $_POST['vorname'];
$nachname = $_POST['nachname'];
$passwort = rand(0, 999999);
$result = $con->query("SELECT email FROM signup WHERE email = $email");
if($result->num_rows == 0) {
$sql = "INSERT INTO signup (vorname, nachname, email, Passwort) vALUES ($vorname, $nachname, $email, $passwort)";
if ($con->query($sql) === TRUE) {
header("Location: Login.html");
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
} else {
echo "User ist bereits registriert";
}
$mysqli->close();
?>
Do you notice an error ?
The error message says that the array keys are not defined
e.g.:Warning: Undefined array key “email” in C:xampphtdocsKulinariksignup_save.php on line 9
Thanks in advance
Hello experts I would be very happy about your help