Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.07 KB | None | 0 0
  1. w8_view_startpage.php:
  2.  
  3. <div id='signin' class='modal-window'>
  4.         <h2 style='text-align:center'>Sign In</h2>
  5.         <br>
  6.         <form method='post' action='w4_controller.php'>
  7.             <input type='hidden' name='page' value='StartPage'></input>
  8.             <input type='hidden' name='command' value='SignIn'></input>
  9.             <label class='modal-label'>Username:</label>
  10.             <input type='text' name='username' placeholder='Enter username' required></input>
  11.             <br>
  12.             <label class='modal-label'>Password:</label>
  13.             <input type='password' name='password' placeholder='Enter password' required></input>
  14.             <br>
  15.             <br>
  16.             <button type='submit' value='Submit'>Submit</button>
  17.             <button type='reset' value='Reset'>Reset</button>
  18.             <button id='cancel-signin' type='cancel' value='Cancel'>Cancel</button>
  19.         </form>
  20.     </div>
  21.  
  22.     <div id='join' class='modal-window'>
  23.         <h2 style='text-align:center'>Join</h2>
  24.         <br>
  25.         <form method='post' action='w4_controller.php'>
  26.             <input type='hidden' name='page' value='StartPage'></input>
  27.             <input type='hidden' name='command' value='Join'></input>
  28.            
  29.             <label class='modal-label'>Username:</label>
  30.             <input type='text' name='username' placeholder='Enter username' required></input>
  31.             <br>
  32.             <label class='modal-label'>Password:</label>
  33.             <input type='password' name='password' placeholder='Enter password' required></input>
  34.             <br>
  35.             <label class='modal-label'>Email:</label>
  36.             <input type='text' name='email' placeholder='Enter email address' required></input>
  37.             <br>
  38.             <br>
  39.             <button type='submit' value='Submit'>Submit</button>
  40.             <button type='reset' value='Reset'>Reset</button>
  41.             <button id='cancel-join' type='cancel' value='Cancel'>Cancel</button>
  42.         </form>
  43.     </div>
  44.  
  45.  
  46.  
  47. w4_controller.php
  48.  
  49. <?php
  50. require('w4_model.php');  // This file includes some routines to use DB.
  51.               // E.g., is_valid() to check the validity of username and password.
  52. //...
  53.  
  54. // When commands come from StartPage
  55. if ($_POST['page'] == 'StartPage')  // Check the page value
  56. {
  57.    $command = $_POST['page'];
  58.    switch($command) {  // When a command is sent from the client
  59.        case 'SignIn':  // With username and password
  60. //          if (there is an error in username and password) {
  61.            if (!is_valid($_POST['username'], $_POST['password'])) {  // This function is defined in Model.
  62.                include('w4_view_startpage.php');  // Include the start page
  63.            } else
  64.                include('w4_view_mainpage.php')  // Include the main page
  65.            exit();
  66.            
  67.        case 'Join':  // With username, password, email, some other information
  68.            //...
  69.            exit();
  70.        //...
  71.        
  72.         default:
  73.             exit();
  74.    }
  75. }
  76.  
  77. // When commands come from 'MainPage'
  78. //   Not implemented yet
  79. else {
  80.    //...
  81. }
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement