Advertisement
exolon

sign-up

Jun 21st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.59 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once('class.user.php');
  4. $user = new USER();
  5.  
  6. if($user->is_loggedin()!="")
  7. {
  8.     $user->redirect('home.php');
  9. }
  10.  
  11. if(isset($_POST['btn-signup']))
  12. {
  13.     $uname = strip_tags($_POST['txt_nomecognome']);
  14.     $umail = strip_tags($_POST['txt_matricola']);
  15.     $upass = strip_tags($_POST['txt_password']);   
  16.    
  17.     if($uname=="")  {
  18.         $error[] = "provide username !";   
  19.     }
  20.     else if($umail=="") {
  21.         $error[] = "provide matricola id !";   
  22.     }
  23.    
  24.     else if($upass=="") {
  25.         $error[] = "provide password !";
  26.     }
  27.     else if(strlen($upass) < 6){
  28.         $error[] = "Password must be atleast 6 characters";
  29.     }
  30.     else
  31.     {
  32.         try
  33.         {
  34.             $stmt = $user->runQuery("SELECT user_nomecognome, user_matricola FROM users WHERE user_nomecognome=:uname OR user_matricola=:umail");
  35.             $stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
  36.             $row=$stmt->fetch(PDO::FETCH_ASSOC);
  37.                
  38.             if($row['user_nomecognome']==$uname) {
  39.                 $error[] = "sorry username already taken !";
  40.             }
  41.             else if($row['user_matricola']==$umail) {
  42.                 $error[] = "sorry matricola id already taken !";
  43.             }
  44.             else
  45.             {
  46.                 if($user->register($uname,$umail,$upass)){ 
  47.                     $user->redirect('sign-up.php?joined');
  48.                 }
  49.             }
  50.         }
  51.         catch(PDOException $e)
  52.         {
  53.             echo $e->getMessage();
  54.         }
  55.     }  
  56. }
  57.  
  58. ?>
  59. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  60. <html xmlns="http://www.w3.org/1999/xhtml">
  61. <head>
  62. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  63. <title>Coding Cage : Sign up</title>
  64. <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
  65. <link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
  66. <link rel="stylesheet" href="style.css" type="text/css"  />
  67. </head>
  68. <body>
  69.  
  70. <div class="signin-form">
  71.  
  72. <div class="container">
  73.        
  74.         <form method="post" class="form-signin">
  75.             <h2 class="form-signin-heading">Sign up.</h2><hr />
  76.             <?php
  77.             if(isset($error))
  78.             {
  79.                 foreach($error as $error)
  80.                 {
  81.                      ?>
  82.                      <div class="alert alert-danger">
  83.                         <i class="glyphicon glyphicon-warning-sign"></i> &nbsp; <?php echo $error; ?>
  84.                      </div>
  85.                      <?php
  86.                 }
  87.             }
  88.             else if(isset($_GET['joined']))
  89.             {
  90.                  ?>
  91.                  <div class="alert alert-info">
  92.                       <i class="glyphicon glyphicon-log-in"></i> &nbsp; Successfully registered <a href='index.php'>login</a> here
  93.                  </div>
  94.                  <?php
  95.             }
  96.             ?>
  97.             <div class="form-group">
  98.             <input type="text" class="form-control" name="txt_matricola" placeholder="Enter Matricola" value="<?php if(isset($error)){echo $uname;}?>" />
  99.             </div>
  100.             <div class="form-group">
  101.             <input type="text" class="form-control" name="txt_nomecognome" placeholder="Nome e Cognome" value="<?php if(isset($error)){echo $umail;}?>" />
  102.             </div>
  103.             <div class="form-group">
  104.                 <input type="password" class="form-control" name="txt_password" placeholder="Enter Password" />
  105.             </div>
  106.             <div class="clearfix"></div><hr />
  107.             <div class="form-group">
  108.                 <button type="submit" class="btn btn-primary" name="btn-signup">
  109.                     <i class="glyphicon glyphicon-open-file"></i>&nbsp;SIGN UP
  110.                 </button>
  111.             </div>
  112.             <br />
  113.             <label>have an account ! <a href="index.php">Sign In</a></label>
  114.         </form>
  115.        </div>
  116. </div>
  117.  
  118. </div>
  119.  
  120. </body>
  121. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement