Advertisement
Guest User

Untitled

a guest
Apr 14th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "chris16422";
  5.  
  6. $conn = mysqli_connect($servername, $username, $password);
  7.  
  8. if (!$conn) {
  9.                 die("connection failed: " . mysqli_connect_error());
  10. }
  11. echo "connection successful";
  12. ?>
  13.  
  14. <?php
  15.        
  16.     // If the values are posted, insert them into the database.
  17.     if (isset($_POST['username']) && isset($_POST['password'])){
  18.         $username = $_POST['username'];
  19.         $email = $_POST['email'];
  20.         $password = $_POST['password'];
  21.  
  22.         $query = "INSERT INTO `user` (username, password, email) VALUES ('$username', '$password', '$email')";
  23.         $result = mysqli_query($conn, $query);
  24.         if($result){
  25.             $smsg = "User Created Successfully.";
  26.         }else{
  27.             $fmsg ="User Registration Failed";
  28.         }
  29.     }
  30.     ?>
  31.  
  32. <div class="container">
  33.       <form class="form-signin" method="POST">
  34.       <?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
  35.       <?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>
  36.         <h2 class="form-signin-heading">Please Register</h2>
  37.         <div class="input-group">
  38.           <span class="input-group-addon" id="basic-addon1">@</span>
  39.           <input type="text" name="username" class="form-control" placeholder="Username" required>
  40.         </div>
  41.         <label for="inputEmail" class="sr-only">Email address</label>
  42.         <input type="email" name="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
  43.         <label for="inputPassword" class="sr-only">Password</label>
  44.         <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
  45.         <button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
  46.         <a class="btn btn-lg btn-primary btn-block" href="login.php">Login</a>
  47.       </form>
  48. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement