<?php
if(session_start()) {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Registration</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<?php
$_REQUEST = array('username' => 'io', 'check' => 'Register');
// When form submitted, insert values into the database.
if (isset($_REQUEST['check'])) {
//require('db.php');
// removes backslashes
/*$username = stripslashes($_REQUEST['username']);
//escapes special characters in a string
$username = mysqli_real_escape_string($con, $username);
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($con, $email);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con, $password);
$create_datetime = date("Y-m-d H:i:s");
$query = "INSERT into `users` (username, password, email, create_datetime)
VALUES ('$username', '" . md5($password) . "', '$email', '$create_datetime')";
$result = mysqli_query($con, $query);*/
$result = true;
if ($result) {
?>
<div class="form">
<h3>You are registered successfully.</h3><br/>
<p class="link">Click here to <a href="login.php">Login</a></p>
</div>
<?php
} else {
?>
<div class="form">
<h3>Required fields are missing.</h3><br/>
<p class="link">Click here to <a href="registration.php">registration</a> again.</p>
</div>
<?php
}
} else {
?>
<form class="form" action="" method="post">
<h1 class="login-title">Registration</h1>
<input type="text" class="login-input" name="username" placeholder="Username" required />
<input type="text" class="login-input" name="email" placeholder="Email Adress">
<input type="password" class="login-input" name="password" placeholder="Password">
<input type="submit" name="check" value="Register" class="login-button">
<p class="link">Already have an account? <a href="login.php">Login here</a></p>
</form>
<?php
}
} else {
echo 'Session not work';
}
?>
</body>
</html>
preferences:
28.5 ms | 404 KiB | 5 Q