Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
63
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 ('$_POST[account]', '$_POST[password]', '$_POST[email]', '1')");
  25.                 $result=mysql_query($sql);
  26.  
  27.                 $count=mysql_num_rows($result);
  28.  
  29.                 if($count==1){
  30.             echo "Your account has been registered";
  31.                 }
  32.                 else {
  33.                 echo 'Registration failed.';
  34.                 }
  35.             break;
  36.             }
  37.        }
  38.        else
  39.         {
  40.                 echo "<html>
  41.                <body>
  42.  
  43.                <form action="?action=register" method="post">
  44.                Account:      <input type="text" name="account" /><br><br>
  45.                Password:   <input type="password" name="password" /><br><br>
  46.             Email: <input type="text" name="email" /><br><br>
  47.                <input type="submit" value="Register" />
  48.                </form>
  49.  
  50.                </body>
  51.                </html>";
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement