So I am attempting to create a simple sign up form, just with Username and Email as I’m just testing things, and I keep getting the following error:
_Notice: Undefined index: username in C:\xampp\htdocs\tes\createacc.php on line 5
Notice: Undefined index: email in C:\xampp\htdocs\tes\createacc.php on line 6_
This is my code:
<?php
session_start();
require_once 'dbc.php';
if(isset($_POST['submit'])) {
$username = strip_tags($_POST['username']);
$email = strip_tags($_POST['email']);
$username = $DBcon->real_escape_string($username);
$email = $DBcon->real_escape_string($email);
$check_username = $DBcon->query("SELECT username FROM users WHERE username='$username'");
$count=$check_username->num_rows;
if ($count==0) {
$query = "INSERT INTO users(username,email) VALUES('$username','$email')";
if ($DBcon->query($query)) {
echo "Created";
}else {
echo "Error";
}
} else {
echo "In-use";
}
$DBcon->close();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login</title>
<link href="/fonts" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="login-page">
<div class="form">
<form class="registration-form">
<form action="" method="post">
<input type="text" name="username" id="username" placeholder="Username"/>
</form>
<form action="" method="post">
<input type="password" name="password" id="password" placeholder="Password"/>
</form>
<form action="" method="post">
<input type="text" name="email" id="email" placeholder="Email Address"/>
</form>
<form action="" method="post">
<input type="submit" name="submit" id="submit" value="Create Account">
</form>
<p class="message">Already registered? <a href="login.php">Sign In</a></p>
</form>
</div>
<center><i><font size="1">Copyright (C) 2017 - Please read <a href="tou.php">Terms of Use</a>.</i></center>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
I’m still new, so sorry for any simple mistakes.