Advertisement
Guest User

auth

a guest
May 24th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. require_once('dbauth.php');
  5.  
  6. if(isset($_POST['id'])) {
  7.     // Registration or Login has been sumbitted.
  8.  
  9.     if(isset($_POST['checkbox'])) {
  10.         // Register user.
  11.  
  12.         // There's no nice way to break out of nested if statements in PHP...
  13.         switch(true) {
  14.             case true:
  15.                 // so I cheat and break out of switch cases instead.
  16.                 if(!isset($_POST['confirm'])) {
  17.                     echo '<div class="error">Password Confirmation field is empty.</div>';
  18.                     break;
  19.                 }
  20.                 if($_POST['pass'] != $_POST['confirm']) {
  21.                     echo '<div class="error">Passwords do not match.</div>';
  22.                     break;
  23.                 }
  24.             break;
  25.         }
  26.  
  27.         register_user( $_POST['id'], $_POST['pass'] );
  28.     }
  29.     else {
  30.         // Login.
  31.         login_user( $_POST['id'], $_POST['pass'] );
  32.     }
  33. }
  34.  
  35. if(isset($_SESSION['userid'])) {
  36.     header('Location:http://s.scon.es/');
  37. }
  38.  
  39. ?>
  40.  
  41. <form>
  42.  
  43. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement