Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     require_once('dbconfig/config.php');
  4.     //phpinfo();
  5.             if(isset($_POST['register']))
  6.             {
  7.                 $username=$_POST['username'];
  8.                 $password=$_POST['password'];
  9.                 $cpassword=$_POST['cpassword'];
  10.                
  11.                 if($password==$cpassword)
  12.                 {
  13.                     $query = "select * from userinfotbl where username='$username'";
  14.                     //echo $query;
  15.                 $query_run = mysqli_query($con,$query);
  16.                 //echo mysql_num_rows($query_run);
  17.                 if($query_run)
  18.                     {
  19.                         if(mysqli_num_rows($query_run)>0)
  20.                         {
  21.                             echo '<script type="text/javascript">alert("This Username Already exists.. Please try another username!")</script>';
  22.                         }
  23.                         else
  24.                         {
  25.                             $query = "insert into userinfotbl values('$username','$password')";
  26.                             $query_run = mysqli_query($con,$query);
  27.                             if($query_run)
  28.                             {
  29.                                 echo '<script type="text/javascript">alert("User Registered.. Welcome")</script>';
  30.                                 $_SESSION['username'] = $username;
  31.                                 $_SESSION['password'] = $password;
  32.                                 header( "Location: homepage.php");
  33.                             }
  34.                             else
  35.                             {
  36.                                 echo '<p class="bg-danger msg-block">Registration Unsuccessful due to server error. Please try later</p>';
  37.                             }
  38.                         }
  39.                     }
  40.                     else
  41.                     {
  42.                         echo '<script type="text/javascript">alert("DB error")</script>';
  43.                     }
  44.                 }
  45.                 else
  46.                 {
  47.                     echo '<script type="text/javascript">alert("Password and Confirm Password do not match")</script>';
  48.                 }
  49.                
  50.             }
  51.             else
  52.             {
  53.             }
  54. ?>
  55. <!DOCTYPE html>
  56. <html>
  57. <head>
  58. <title>Sign Up Page</title>
  59. <link rel="stylesheet" href="css/style.css">
  60. </head>
  61. <body style="background-color:#bdc3c7">
  62.     <div id="main-wrapper">
  63.     <center><h2>Sign Up Form</h2></center>
  64.         <form action="register.php" method="post">
  65.             <div class="imgcontainer">
  66.                 <img src="imgs/avatar.png" alt="Avatar" class="avatar">
  67.             </div>
  68.             <div class="inner_container">
  69.                 <label><b>Username</b></label>
  70.                 <input type="text" placeholder="Enter Username" name="username" required>
  71.                 <label><b>Password</b></label>
  72.                 <input type="password" placeholder="Enter Password" name="password" required>
  73.                 <label><b>Confirm Password</b></label>
  74.                 <input type="password" placeholder="Enter Password" name="cpassword" required>
  75.                 <button name="register" class="sign_up_btn" type="submit">Sign Up</button>
  76.                
  77.                 <a href="index.php"><button type="button" class="back_btn"><< Back to Login</button></a>
  78.             </div>
  79.         </form>
  80.     </div>
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement