Im countering sort of a weird problem at this moment. I made a simple login form, it works halfway thru. You can indeed write your name in and such but once you hit the Submit button, I get some " Undefined index: nameX" symbols eventho I have added the variable for it before the function and such.
This is the content of the sql_connection.sql (well part of it you have to see atleast)
/* Registration */
$nameX = $_POST['name'];
$query = isRegistered($_POST['name']); //this will check if they are valid or not
if(isset($_POST['submit'])) {
if(!empty($_POST['name'])) {
if($query == true) {
echo "Welcome back";
}
}
else {
echo "No accounts found";
}
}
function isRegistered($name) {
global $handler;
$query = "SELECT ID FROM players WHERE Username= '".$name."'";
$result = mysqli_query($handler, $query);
if(mysqli_num_rows($result) != 0) {
while($row = mysqli_fetch_assoc($result)) {
return true;
}
}
else {
return false;
}
}
and this is the actual form
<div id="login">
<form action="includes/sql_connection.php" method="get">
First name: <input type="text" name="name"><br>
<input id="button" type="submit" name="submit" value="Sign-Up">
</form>
</div>
The error
Notice: Undefined index: name in C:\wamp\www\php\includes\sql_connection.php on line 101
and the error line (line: 101)
$nameX = $_POST['name'];