Skip to content

Instantly share code, notes, and snippets.

@lablnet
Created July 24, 2018 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lablnet/d29f49c766692fa375f3aa16cae33fea to your computer and use it in GitHub Desktop.
Save lablnet/d29f49c766692fa375f3aa16cae33fea to your computer and use it in GitHub Desktop.
Fixed error
<?php
function sanitizeInput ($inputText){
$inputText = strip_tags($inputText);
$inputText = str_replace(" ", "", $inputText);
return $inputText;
}
function sanitizeString ($inputText){
$inputText = strip_tags($inputText);
$inputText = str_replace(" ", "", $inputText);
$inputText = ucfirst(strtolower($inputText));
return $inputText;
}
function sanitizePassword ($inputText){
$inputText = sanitizeInput($inputText);
return $inputText;
}
if(isset($_POST['loginButton'])){
// Login Button is pressed
}
if(isset($_POST['registerButton'])){
// Register Button is pressed
$username = sanitizeInput($_POST['username']);
$firstName = sanitizeString($_POST['firstName']);
$lastName = sanitizeString($_POST['lastName']);
$email = sanitizeString($_POST['email']);
$email2 = sanitizeString($_POST['email2']);
$password = sanitizePassword($_POST['password']);
$password2 = sanitizePassword($_POST['password2']);
if ($email === $email2) {
if ($password === $password2){
//Continue
} else {
echo "Email much be same";
}
} else {
echo "Password much be same";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width,initial-scale=1">
<title> Welcome to Slotify </title>
</head>
<body>
<div id="inputContainer">
<form id="loginForm" action="register.php" method="POST">
<h2>Login to your Account</h2>
<p>
<label for="loginUsername">Username :</label>
<input id="loginUsername" type="text" name="loginUsername" placeholder="e.g. bartSimson" required>
</p>
<p>
<label for="loginPassword">Password :</label>
<input id="loginPassword" type="password" placeholder="Your Password" name="loginPassword" required>
</p>
<button type="submit" name="loginButton">LOGIN</button>
</form>
<form id="registerForm" action="register.php" method="POST">
<h2>Create Your free Account</h2>
<p>
<label for="username">Username :</label>
<input id="username" type="text" name="username" placeholder="e.g. bartSimson" required>
</p>
<p>
<label for="firstName">First Name :</label>
<input id="firstName" type="text" name="firstName" placeholder="e.g. Bart" required>
</p>
<p>
<label for="lastName">Last Name :</label>
<input id="lastName" type="text" name="lastName" placeholder="e.g. Simson" required>
</p>
<p>
<label for="email">Email :</label>
<input id="email" type="email" name="email" placeholder="e.g. bartsimson@gmail.com" required>
</p>
<p>
<label for="email2">Confirm Email :</label>
<input id="email2" type="email" name="email2" placeholder="e.g. bartsimson@gmail.com" required>
</p>
<p>
<label for="password">Password :</label>
<input id="password" name='password' type="password" placeholder="Your Password" required>
</p>
<p>
<label for="password2">Confirm Password :</label>
<input id="password2" name='password2' placeholder="Confirm Password" type="password" required>
</p>
<button type="submit" name="registerButton">SignUp</button>
</form>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment