Advertisement
Guest User

Untitled

a guest
Nov 4th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.70 KB | None | 0 0
  1. <?php
  2. define('DB_USERNAME','root');
  3. define('DB_PASSWORD','');
  4. define('DB_DATABASE','enterprisecoursework');
  5.  
  6. $conn = mysqli_connect('localhost', DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die(mysqli_error());
  7. $dbcon = mysqli_select_db($conn, DB_DATABASE);
  8.  
  9.  
  10. if (!$conn) {
  11.     die("Connection failed: " . mysqli_error());
  12. }
  13. echo "connected fine";
  14.  
  15.     //require('db/db_connect.php');
  16.     // If the values are posted, insert them into the database.
  17.    
  18.     if (isset($_POST['username']) && isset($_POST['password'])){
  19.    
  20.         $username = $_POST['username'];
  21.         $email = $_POST['email'];
  22.         $password = $_POST['password'];
  23.        
  24.         switch($_POST['acc_choice']) {
  25.             case "2":
  26.                 $account = $_POST['acc_choice'];
  27.             case "3":
  28.                 $account = $_POST['acc_choice'];
  29.             default:
  30.                 $account = $_POST['acc_choice'];
  31.                 $verified = 1;
  32.         }
  33.         $loggedIn = 0;
  34.         $verified = 0;
  35.  
  36.        
  37.         $query = "INSERT INTO 'users' (username, password, email, loggedIn, accountType, verified )
  38. VALUES('$username', '$password', '$email', '$loggedIn', '$accType', '$verified')";
  39.  
  40.         $final = mysqli_query($conn, $query);
  41.        
  42.         if($final){
  43.             $msg = "User Created Successfully.";
  44.         }else{
  45.             $msg = "User Registration Failed";
  46.         }
  47.         echo $msg; 
  48.     }
  49.     mysqli_close($conn);
  50.     ?>
  51.  
  52.  
  53. <?php include ('inc/header.php'); ?>
  54.  
  55. <body>
  56. <div class="container">
  57.     <div id="login-form">
  58.         <form method="POST" action="index.php" autocomplete="off">
  59.  
  60.             <div class="infoContainer">
  61.  
  62.                 <div class="group">
  63.                     <h2 class="">Sign Up</h2>
  64.                 </div>
  65.  
  66.                 <?php
  67.                 if ( isset($errMSG) ) {
  68.  
  69.                     ?>
  70.                     <div class="group">
  71.                         <div><?php echo ($errTyp=="success") ? "success" : $errTyp; ?></div>
  72.                             <span><?php echo $errMSG; ?></span>
  73.                         </div>
  74.                     </div>
  75.                     <?php
  76.                 }
  77.                 ?>
  78.  
  79.                 <fieldset>
  80.                     <div class="input-group">
  81.                         <label>Username</label><input type="text" name="name" class="form-control" placeholder="Enter username" maxlength="50" value="" />
  82.                     </div>
  83.  
  84.                     <span class="error"></span>
  85.                     <div class="input-group">
  86.                         <label>Password</label><input type="password" name="pass" placeholder="Enter a password" maxlength="30" value="" />
  87.                     </div>
  88.                     <span class="error"></span>
  89.  
  90.  
  91.                     <div class="input-group">
  92.                         <label>Email</label><input type="email" name="email" placeholder="Enter Your Email" maxlength="50" value="" />
  93.                     </div>
  94.                     <span class="error"></span>
  95.                    
  96.                     <div class="radios">
  97.                         <label>Select an account type</label>
  98.                         <select name="acc_choice">
  99.                             <option value="1">Shopper</option>
  100.                             <option value="2">Photographer</option>
  101.                             <option value="3">Admin</option>
  102.                         </select>
  103.                         <p>Photographer and admin accounts will need to be verified before use. Admin do this within 1 day of registering.</p>
  104.                     </div>
  105.                    
  106.                     <input type="submit" name="registerBtn"/><br />
  107.                     <a href="login.php" style="float: right;">Looking for the login?</a>
  108.                 </fieldset>
  109.  
  110.             </div>
  111.  
  112.  
  113.  
  114.         </form>
  115.     </div>
  116. </div>
  117. </div>
  118. <?php include ('inc/footer.php'); ?>
  119. </body>
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement