SHARE
TWEET

Untitled

a guest May 27th, 2018 149 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  ob_start();
  3.  session_start();
  4.  if(isset($_SESSION['user'])!="" ){
  5.   header("Location: home.php");
  6.  }
  7.  include_once 'dbconnect.php';
  8.  
  9.  $error = false;
  10.  
  11.  if ( isset($_POST['btn-signup']) ) {
  12.  
  13.   // clean user inputs to prevent sql injections
  14.   $name = trim($_POST['name']);
  15.   $name = strip_tags($name);
  16.   $name = htmlspecialchars($name);
  17.  
  18.   $email = trim($_POST['email']);
  19.   $email = strip_tags($email);
  20.   $email = htmlspecialchars($email);
  21.  
  22.   $pass = trim($_POST['pass']);
  23.   $pass = strip_tags($pass);
  24.   $pass = htmlspecialchars($pass);
  25.  
  26.  
  27.   // basic name validation
  28.   $nquery = "SELECT userName FROM users WHERE userName='$name'";
  29.   $nresult = mysql_query($nquery);
  30.   $ncount = mysql_num_rows($nresult);
  31.   if (empty($name)) {
  32.    $error = true;
  33.    $nameError = "Please enter username";
  34.   } else if (strlen($name) < 3) {
  35.    $error = true;
  36.    $nameError = "Name must have atleat 3 characters.";
  37.   } else if (!preg_match("/^[a-zA-Z]+$/",$name)) {
  38.    $error = true;
  39.    $nameError = "Name must only contain letters (a-z, A-Z).";
  40.   } else if ($ncount!=0){
  41.     $error = true;
  42.     $nameError = "Provided Name is already in use.";
  43.    }
  44.  
  45.   //basic email validation
  46.   if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
  47.    $error = true;
  48.    $emailError = "Please enter valid email address.";
  49.   } else {
  50.    // check email exist or not
  51.    $query = "SELECT userEmail FROM users WHERE userEmail='$email'";
  52.    $result = mysql_query($query);
  53.    $count = mysql_num_rows($result);
  54.    if($count!=0){
  55.     $error = true;
  56.     $emailError = "Provided Email is already in use.";
  57.    }
  58.   }
  59.   // password validation
  60.   if (empty($pass)){
  61.    $error = true;
  62.    $passError = "Please enter password.";
  63.   } else if(strlen($pass) < 6) {
  64.    $error = true;
  65.    $passError = "Password must have atleast 6 characters.";
  66.   }
  67.  
  68.   // password encrypt using SHA256();
  69.   $password = hash('sha256', $pass);
  70.  
  71.   // if there's no error, continue to signup
  72.   if( !$error ) {
  73.    
  74.    $query = "INSERT INTO users(userName,userEmail,userPass) VALUES('$name','$email','$password')";
  75.    $res = mysql_query($query);
  76.    
  77.    if ($res) {
  78.     $errTyp = "success";
  79.     $errMSG = "Successfully registered, you may login now";
  80.     unset($name);
  81.     unset($email);
  82.     unset($pass);
  83.    } else {
  84.     $errTyp = "danger";
  85.     $errMSG = "Something went wrong, try again later...";
  86.    }
  87.    
  88.   }
  89.  
  90.  
  91.  }
  92. ?>
  93. <!DOCTYPE html>
  94. <html>
  95.   <head>
  96.     <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  97. <script>
  98.   (adsbygoogle = window.adsbygoogle || []).push({
  99.     google_ad_client: "ca-pub-9530173388628451",
  100.     enable_page_level_ads: true
  101.   });
  102. </script>
  103.     <title>Account | astaspasta</title>
  104.     <meta charset="utf-8">
  105.     <link href="style.css" rel="stylesheet" type="text/css">
  106.   </head>
  107.   <body>
  108.      <ul class="Navi1">
  109.       <li class="li1"><a class="hu" href="index.php">Home</a></li>
  110.       <li class="li1"><a class="hu" href="Info.php">Info</a></li>
  111.       <li class="li1 donate"><a class="hu" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9MY9VK2WG58T2" target="_blank">Donate</a></li>
  112.       <li class="li1 acc active"><a class="hu ani1" href="account.php">        <?php
  113.         echo "<b style= float: left;>";
  114.         if (file_exists("ProfilePics/".$name.".png")) {
  115.          echo "<img class= \"navpico\" src=\"ProfilePics/". $name .".png\" alt=\"ProfilePicture\">";
  116.         } else if (file_exists("ProfilePics/".$name.".jpg")) {
  117.          echo "<img class= \"navpico\" src=\"ProfilePics/". $name .".jpg\" alt=\"ProfilePicture\">";
  118.         } else if (file_exists("ProfilePics/".$name.".jpeg")) {
  119.          echo "<img class= \"navpico\" src=\"ProfilePics/". $name .".jpeg\" alt=\"ProfilePicture\">";
  120.         }
  121.       echo "</b>&nbsp;";
  122.       if ($name!="") {echo $name; } else { echo "Account";}
  123.       ?></a></li>
  124.             <?php
  125.       if ($name!="") {
  126.         echo "<li class=\"li1 searchnav\"><a class=\"hu\" href=\"search.php\"><img class= \"navpico\" src=\"Images/Search_Main.png\" alt=\"Search\"></a></li>";
  127.       }
  128.       ?>
  129.      </ul>
  130.  
  131.   <br>
  132.   <br>
  133.  
  134. <center>
  135. <div class="container" style="border: darkcyan solid; border-radius: 10px; background-color: darkcyan; width: 45%;">
  136.  
  137.  <div id="login-form">
  138.     <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">
  139.    
  140.      <div class="col-md-12">
  141.        
  142.          <div class="form-group">
  143.              <center><h2 style="color: white; font-family: fantasy;">Sign Up</h2></center>
  144.             </div>
  145.        
  146.          <div class="form-group">
  147.              <hr />
  148.             </div>
  149.  
  150.     <div class="form-group">
  151.              <div class="alert alert-<?php echo ($errTyp=="success") ? "success" : $errTyp; ?>">
  152.     <span class="glyphicon glyphicon-info-sign" style="color: red; font-family: fantasy;"><?php echo $errMSG; ?></span>
  153.                 </div>
  154.              </div>
  155.  
  156.            
  157.             <div class="form-group">
  158.              <div class="input-group">
  159.                 <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
  160.              <input type="text" name="name" class="form-control" placeholder="Enter Name" maxlength="50" value="<?php echo $name ?>" />
  161.                 </div>
  162.                 <span class="text-danger" style="color: red; font-family: fantasy;"><?php echo $nameError; ?></span>
  163.             </div>
  164.            
  165.             <div class="form-group">
  166.              <div class="input-group">
  167.                 <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
  168.              <input type="email" name="email" class="form-control" placeholder="Enter Your Email" maxlength="40" value="<?php echo $email ?>" />
  169.                 </div>
  170.                 <span class="text-danger" style="color: red; font-family: fantasy;"><?php echo $emailError; ?></span>
  171.             </div>
  172.            
  173.             <div class="form-group">
  174.              <div class="input-group">
  175.                 <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
  176.              <input type="password" name="pass" class="form-control" placeholder="Enter Password" maxlength="15" />
  177.                 </div>
  178.                 <span class="text-danger" style="color: red; font-family: fantasy;"><?php echo $passError; ?></span>
  179.             </div>
  180.            
  181.             <div class="form-group">
  182.              <hr />
  183.             </div>
  184.            
  185.             <div class="form-group">
  186.              <button type="submit" class="btn btn-block btn-primary" name="btn-signup">Sign Up</button>
  187.             </div>
  188.            
  189.             <div class="form-group">
  190.              <hr />
  191.             </div>
  192.            
  193.             <div class="form-group">
  194.               <center><a href="account.php" style="color: white; font-family: fantasy;" class="hu">Sign in Here...</a></center>
  195.             </div>
  196.        
  197.         </div>
  198.    
  199.     </form>
  200.     </div>
  201.  
  202. </div>
  203. </center>
  204. </body>
  205. </html>
  206. <?php ob_end_flush(); ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top