Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1.       <?php
  2.         $con = mysql_connect("localhost","root","wow");
  3.         if (!$con)
  4.         {
  5.                 die('Could not connect: ' . mysql_error());
  6.         }
  7.        
  8.         mysql_select_db("login", $con) or die (mysql_error ());
  9.  
  10.         if(isset($_GET['action']))
  11.         {
  12.                 switch($_GET['action'])
  13.                 {
  14.                 case 'register':
  15.             $registerusername=$_POST['account'];
  16.                 $registerpassword=$_POST['password'];
  17.  
  18.                 $registerusername = stripslashes($registerusername);
  19.                 $registerpassword = stripslashes($registerpassword);
  20.                 $registerusername = mysql_real_escape_string($registerusername);
  21.                 $registerpassword = mysql_real_escape_string($registerpassword);
  22.  
  23.                 $sql="INSERT INTO accounts (account, password, email, access)
  24.         VALUES
  25.         ('$_POST[account]', '$_POST[password]', '$_POST[email]', '1')");
  26.                 $result=mysql_query($sql);
  27.  
  28.                 $count=mysql_num_rows($result);
  29.  
  30.                 if($count==1){
  31.             echo "Your account has been registered";
  32.                 }
  33.                 else {
  34.                 echo 'Registration failed.';
  35.                 }
  36.             break;
  37.             }
  38.        }
  39.        else
  40.         {
  41.                 echo "<html>
  42.                <body>
  43.  
  44.                <form action="?action=register" method="post">
  45.                Account:      <input type="text" name="account" /><br><br>
  46.                Password:   <input type="password" name="password" /><br><br>
  47.             Email: <input type="text" name="email" /><br><br>
  48.                <input type="submit" value="Register" />
  49.                </form>
  50.  
  51.                </body>
  52.                </html>";
  53.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement