Hi all,
I decided to come back to the world of PHP and, just like how I left it, fall for all the basic errors...
I'm trying to create a login script for my website but for some unknown reason this produces an Internal Error (500).
I'm not sure what part in the script causes this so I'm posting the whole script.
(Error 500's are usually caused (with my site anyway) by a missing semicolon or something stupid)
Thanks in advance!
if (isset($_COOKIE["Username"])){
echo "<did><p><b>Welcome, ".$_SESSION["Username"]."!</b></p></div>";
}else{
if(isset($_POST['Submit'])) {
if(!empty($_POST['Username'])){
if(!empty($_POST['Password'])){
$mysqli = new mysqli([Removed]);
$Username = $mysqli->real_escape_string($_POST['Username']);
$Password = md5($_POST['Password']);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$Result = $mysqli->query("SELECT * FROM `Users` WHERE `Username` = '$Username' && `Password` = '$Password'");
if($Result->num rows === 1){
$Expires = 1000 * 60 * 60 * 24;
setcookie("Username", $Result['Username'], time()+$Expires);
}else{
echo '<div class="LoginError"><p>That Username or Password is wrong!</p></div>';
}
}else{
echo'<div class="LoginError"><p>Please enter your Username and Password!</p></div>';
}
}else{
echo'<div class="LoginError"><p>Please enter your Username and Password!</p></div>';
}
}
echo <<<END
<form id="Login" Method ="post" Action = "http://thefunnyzone.co.uk/index.php" accept-charset='UTF-8'>
<fieldset style="border: none;">
<label style="position: relative;">Username:</label>
<input Type="Text" name="Username" class="text-input" style="position: relative;"/>
<label style="position: relative;">Password:</label>
<input Type="Password" name="Password" class="text-input" style="position: relative;"/>
<input Type="Submit" Name="Submit" Value="Login" style="position: relative;"/>
</fieldset>
</form>
END;
}