Advertisement
Guest User

Untitled

a guest
May 11th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.53 KB | None | 0 0
  1. <?php
  2. session_start();
  3. // reg.php
  4. require('header.html');
  5. ?>
  6.  
  7.  
  8. <h1>Register To Continue</h1>
  9. <div id="wrapper">
  10. <?php
  11.  
  12.  
  13. if ( isset($_POST['submitted']) ) {
  14.  
  15.     $problem = FALSE; // No problems so far.
  16.    
  17.     // Check for each value...
  18.     if (empty($_POST['first_name'])) {
  19.         $problem = TRUE;
  20.         $ERROR_NAME = '<span class="error">Please enter your first name!</span>';
  21.     }
  22.  
  23.     if ((empty($_POST['title'])) || (($_POST['title'] == "Other") && (empty($_POST['other_title'])))) {
  24.         $problem = TRUE;
  25.         $ERROR_TITLE = '<span class="error">Please enter your title!</span>';
  26.     }
  27.  
  28.     if (empty($_POST['gender'])) {
  29.         $problem = TRUE;
  30.         $ERROR_GEND = '<span class="error">Please select your gender!</span>';
  31.     }
  32.  
  33.     if ((empty($_POST['day'])) || (empty($_POST['month'])) || (empty($_POST['year']))) {
  34.         $problem = TRUE;
  35.         $ERROR_DOB = '<span class="error">Please select your date of birth!</span>';
  36.     }
  37.  
  38.     if (empty($_POST['last_name'])) {
  39.         $problem = TRUE;
  40.         $ERROR_SECOND = '<span class="error">Please enter your last name!</span>';
  41.     }
  42.    
  43.     if (empty($_POST['email'])) {
  44.         $problem = TRUE;
  45.         $ERROR_EMAIL = '<span class="error">Please enter your email address!</span>';
  46.     }
  47.  
  48.     if (empty($_POST['password1'])) {
  49.         $problem = TRUE;
  50.         $ERROR_PASS = '<span class="error">Please enter a password!</span>';
  51.     }
  52.    
  53.     if ($_POST['password1'] != $_POST['password2']) {
  54.         $problem = TRUE;
  55.         $ERROR_NOTSAME = '<span class="error">Your password did not match your confirmed password!</span>';
  56.     }
  57.    
  58.     if (empty($_POST['user'])) {
  59.         $problem = TRUE;
  60.         $ERROR_USERNAME = '<span class="error">Please enter a Username!</span>';
  61.     }
  62.    
  63.     if (!$problem) { // If there weren't any problems...
  64.         $_SESSION['day'] = $_REQUEST['day'];
  65.         $_SESSION['gender'] = $_REQUEST['gender'];
  66.         $_SESSION['month'] = $_REQUEST['month'];
  67.         $_SESSION['year'] = $_REQUEST['year'];
  68.         $_SESSION['email'] = $_REQUEST['email'];
  69.         $_SESSION['fname'] = $_REQUEST['first_name'];
  70.         $_SESSION['sname'] = $_REQUEST['last_name'];
  71.         $_SESSION['pass'] = $_REQUEST['password2'];
  72.         $_SESSION['username'] = $_REQUEST['user'];
  73.     if (($_REQUEST['title']) == "Other") {
  74.         $_SESSION['title'] = $_REQUEST['other_title'];
  75.     }
  76.     else {$_SESSION['title'] = $_REQUEST['title'];}
  77.        
  78.         echo'<META http-equiv="refresh" content="2;URL=registered.php">';
  79.        
  80.         // Clear the posted values:
  81.         $_POST = array();
  82.    
  83.     } else { // Forgot a field.
  84.        
  85.     }
  86.  
  87. } // End of handle form IF.
  88.  
  89. // Create the form:
  90. ?>
  91. <form action="index.php" method="post">
  92. <table id="tab1">
  93. <tr>
  94.   <td>Title:</td>
  95.   <td><select name="title">
  96.   <option value="Mr">Mr</option>
  97.   <option value="Mrs">Mrs</option>
  98.   <option value="Ms">Ms</option>
  99.   <option value="Dr">Dr</option>
  100.   <option value="Other">Other</option>
  101.   </select>
  102.   </td>
  103. </tr>
  104. <tr>
  105.   <td>If other Please State here:</td>
  106.   <td><input name=other_title type=text ></td>
  107.   <td><?php print "$ERROR_TITLE"; ?></td>
  108. </tr>
  109. <tr>
  110.   <td>First Name:</td>
  111.   <td><input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])) { print htmlspecialchars($_POST['first_name']); } ?>" /></td>
  112.   <td><?php print "$ERROR_NAME"; ?></td>
  113. </tr>
  114.  
  115. <tr>
  116.   <td>Last Name:</td>
  117.   <td><input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])) { print htmlspecialchars($_POST['last_name']); } ?>" /></td>
  118.   <td><?php print "$ERROR_SECOND"; ?></td>
  119. </tr>
  120.  
  121. <tr>
  122.   <td rowspan="3">Gender:<td>
  123. </tr>
  124.  
  125. <tr>
  126.   <td>Male
  127.   <input name="gender"
  128. type="radio" value="male"></td>
  129. </tr>
  130.  
  131. <tr>
  132.   <td>Female
  133.   <input name="gender"
  134. type="radio" value="female"></td>
  135.   <td><?php print "$ERROR_GEND"; ?></td>
  136. </tr>
  137.  
  138. <tr>
  139.   <td rowspan="4">Date Of Birth:</td>
  140. </tr>
  141.  
  142. <tr>
  143.     <td>
  144.     <select name="day"><option value="">Day</option>
  145.     <?php
  146.     for ($d = 1; $d <= 31; $d++) {
  147.     print "<option value=\"$d\">$d</option>\n";
  148.     }
  149.     ?></select></td>
  150. </tr>
  151. <tr>
  152.     <td>   
  153.     <select name="month">
  154.     <option value="Month">Month</option>
  155.   <option value="january">January</option>
  156.   <option value="february">February</option>
  157.   <option value="march">March</option>
  158.   <option value="april">April</option>
  159.   <option value="may">May</option>
  160.   <option value="june">June</option>
  161.   <option value="july">July</option>
  162.   <option value="august">August</option>
  163.   <option value="september">September</option>
  164.   <option value="october">October</option>
  165.   <option value="november">November</option>
  166.   <option value="december">December</option>
  167. </select></td>
  168.   <td><?php print "$ERROR_DOB"; ?></td>
  169. </tr>
  170. <tr>
  171. <td>
  172. <select name="year"><option value="">Year</option>
  173.     <?php
  174.     for ($y = 2010; $y >= 1910; $y--) {
  175.     print "<option value=\"$y\">$y</option>\n";
  176.     }
  177.     ?></select></td>
  178. </tr>
  179.  
  180. <tr>
  181.   <td>Email Address:</td>
  182.   <td><input type="text" name="email" size="20" value="<?php if (isset($_POST['email'])) { print htmlspecialchars($_POST['email']); } ?>" /></td>
  183.   <td><?php print "$ERROR_EMAIL"; ?></td>
  184. </tr>
  185.  
  186. <tr>
  187.   <td>Username:</td>   
  188.   <td><input name="user" type="text" value="<?php if (isset($_POST['user'])) { print htmlspecialchars($_POST['user']); } ?>" /></td>
  189.   <td><?php print "$ERROR_USERNAME"; ?></td>
  190. </tr>
  191.  
  192. <tr>
  193.   <td>Password:</td>
  194.   <td><input type="password" name="password1" size="20" /></td>
  195.   <td><?php print "$ERROR_PASS"; ?></td>
  196. </tr>
  197.  
  198. <tr>
  199.   <td>Confirm Password:</td>
  200.   <td><input type="password" name="password2" size="20" /></td>
  201.   <td><?php print "$ERROR_NOTSAME"; ?></td>
  202. </tr>
  203.  
  204. <tr>
  205. <td><input type="submit" name="submit" value="Register!" /></td>
  206. <input type="hidden" name="submitted" value="true" />
  207. </tr>
  208. </form><br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement