Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("includes/connect.php");
- $error = "";
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- $User = mysqli_real_escape_string($db,$_POST['User']);
- $Email = mysqli_real_escape_string($db,$_POST['Email']);
- $Pass = mysqli_real_escape_string($db,$_POST['Pass']);
- $RPass = mysqli_real_escape_string($db,$_POST['RPass']);
- if ($Pass == $RPass) {
- $sqlquery = "SELECT ID FROM users WHERE Email='$Email'";
- $sqlresult = $db->query($sqlquery);
- $sqlquery1 = "SELECT ID FROM users WHERE User='$User'";
- $sqlresult1 = $db->query($sqlquery1);
- if ($sqlresult->num_rows == 0) {
- if ($sqlresult1->num_rows == 0) {
- $options = [
- 'cost' => 12,
- ];
- $hash = password_hash($Pass, PASSWORD_BCRYPT, $options);
- $sqlinsert = "INSERT INTO users (User, Pass, Email) VALUES ('$User', '$hash', '$Email')";
- $db->query($sqlinsert);
- header("location: login.php");
- }else {
- $error = "Username is already in use";
- }
- } else {
- $error = "Email is already in use";
- }
- } else {
- $error = "Passwords didnt match";
- }
- }
- ?>
- <html>
- <head>
- <title>ASG | Signup</title>
- <style type = "text/css">
- body {
- font-family:Arial, Helvetica, sans-serif;
- font-size:14px;
- }
- label {
- font-weight:bold;
- width:100px;
- font-size:14px;
- }
- .box {
- border:#666666 solid 1px;
- margin: 1px;
- }
- .submit {
- border: lightgray solid 1px;
- background-color: white;
- color: black;
- text-align: center;
- text-decoration: none;
- display:inline-block;
- font-size: 16px;
- padding: 4px 12px 4px 12px;
- margin-top: 4px;
- }
- .submit:hover{
- background-color: lightgray;
- border: black solid 1px;
- }
- </style>
- </head>
- <body>
- <form action="" method="post">
- <label>Username: </label><input type="text" name="User" class="box"><br>
- <label>E-mail: </label><input type="email" name="Email" class="box"><br>
- <label>Password: </label><input type="password" name="Pass" class="box"><br>
- <label>Repeat Password: </label><input type="password" name="RPass" class="box"><br>
- <input type="submit" class="submit"><p style = "font-size:15px; color:#cc0000; margin-top:10px; font-weight: bold;"><?php echo $error; ?></p>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement