Advertisement
Guest User

Untitled

a guest
May 27th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <html>
  2.     <center>
  3.     <head>
  4.         <title>Register.</title>
  5.     </head>
  6.         <body>
  7.             <style type="text/css">
  8.                 body { color: red; }
  9.             </style>
  10.             <h1>Register.</h1>
  11.             <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  12.             <strong>Username:</strong><br>
  13.             <input type="text" name="username"><br>
  14.             <strong>Password:</strong><br>
  15.             <input type="password" name="password"><br>
  16.             <strong>Confirm Password</strong><br>
  17.             <input type="password" name="cpass"><br>
  18.             <input type="submit" name="submit" value="Register!"><br>
  19.             </form>
  20.         </body>
  21.        
  22. <?php
  23. #start the session
  24. session_start();
  25.  
  26. #require the config file.
  27. require('config.php');
  28.  
  29. #variables.
  30. $user = stripslashes($_POST['username']);
  31. $pass = stripslashes($_POST['password']);
  32. $cpass = stripslashes($_POST['cpass']);
  33. $user = mysql_escape_string($_POST['username']);
  34. $pass = mysql_escape_string($_POST['password']);
  35. $cpass = mysql_escape_string($_POST['cpass']);
  36. $sub = $_POST['submit'];
  37.  
  38. #if statement to make the database go into mysql.
  39. if (isset($sub)) {
  40.     if (is_string($user) && $pass == $cpass && $pass != "" && $user != "") {
  41.         mysql_query("INSERT INTO `accounts` (user, pass) VALUES ('$user','$cpass')") or die(mysql_error());
  42.         echo "You have successfully registered.";
  43.     }
  44.     else if (isset($userlogged))
  45.         echo "You are logged in please go log out before registering an account.";
  46.     else
  47.         echo "There was a problem with you registering your account, Please go back and try again.";
  48. }  
  49. ?>
  50.  
  51.     </center>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement