Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.01 KB | None | 0 0
  1. <?php
  2.  include 'header.php';
  3.  include 'database_login.php';
  4.  $fields = ["first", "last", "mail", "uname", "age", "pwd", "pwdc"];
  5.  $full = true;
  6.  $errors = [];
  7.  foreach($fields as $f){
  8.     if(!isset($_POST[$f])){
  9.         $full = false;
  10.     }
  11.  }
  12.  if($full){
  13.     /*
  14.      *
  15.      * REGISTERING
  16.      *
  17.      */
  18.     $sql = "SELECT * FROM user WHERE mail=\"".$_POST['mail']."\"";
  19.     $result = mysqli_query($conn_l, $sql);
  20.     $num = mysqli_num_rows($result);
  21.     if($num > 0){
  22.         array_push($errors, "Email is already in use: ".$_POST['mail']);
  23.     }
  24.     $sql = "SELECT * FROM user WHERE uname=\"".$_POST['uname']."\"";
  25.     $result = mysqli_query($conn_l, $sql);
  26.     $num = mysqli_num_rows($result);
  27.     if($num > 0){
  28.         array_push($errors, "Username is already taken:".$_POST['uname']);
  29.     }
  30.     if($_POST['pwd'] != $_POST['pwdc']){
  31.         array_push($errors, "The passwords don't match!");
  32.     }
  33.     if(empty($errors)){
  34.         $sql = "INSERT INTO `user` (`first`, `last`, `mail`, `uname`, `age`, `pwd`) VALUES (\"".htmlentities($_POST['first'])."\", \"".htmlentities($_POST['last'])."\", \"".htmlentities($_POST['mail'])."\", \"".htmlentities($_POST['uname'])."\", ".htmlentities($_POST['age']).", \"".htmlentities($_POST['pwd'])."\")";
  35.         $result = mysqli_query($conn_l, $sql);
  36.     }
  37.  }
  38. ?>
  39.  
  40. <div id="div_breite" class="inhalt">
  41. <h4 style="text-align:left;">Register!</h4>
  42. <?php
  43. if(!empty($errors)){
  44.     foreach ($errors as $e){
  45.         echo "<b>".$e."</b><br>";
  46.     }
  47. }
  48. ?>
  49. <form action="register.php" method="POST">
  50. <table>
  51.     <tr>
  52.         <td>
  53.             <label for="first">First name:</label>
  54.         </td>
  55.         <td>
  56.             <input required maxlength="255" type="text" name="first" id="first"></input>
  57.         </td>
  58.     </tr>
  59.     <tr>
  60.         <td>
  61.             <label for="last">Last name:</label>
  62.         </td>
  63.         <td>
  64.             <input required maxlength="255" type="text" name="last" id="last"></input>
  65.         </td>
  66.     </tr>
  67.     <tr>
  68.         <td>
  69.             <label for="mail">Email:</label>
  70.         </td>
  71.         <td>
  72.             <input required maxlength="255" type="email" name="mail" id="mail"></input>
  73.         </td>
  74.     </tr>
  75.     <tr>
  76.         <td>
  77.             <label for="uname">Username:</label>
  78.         </td>
  79.         <td>
  80.             <input required maxlength="32" type="text" name="uname" id="uname"></input>
  81.         </td>
  82.     </tr>
  83.     <tr>
  84.         <td>
  85.             <label for="uname">Age:</label>
  86.         </td>
  87.         <td>
  88.             <input required min="10" max="100" type="number" name="age" id="age"></input>
  89.         </td>
  90.     </tr>
  91.     <tr>
  92.         <td>
  93.             <label for="pwd">Password:</label>
  94.         </td>
  95.         <td>
  96.             <input required maxlength="255" type="password" name="pwd" id="pwd"></input>
  97.         </td>
  98.     </tr>
  99.     <tr>
  100.         <td>
  101.             <label for="pwdc">Repeat <br>Password:</label>
  102.         </td>
  103.         <td>
  104.             <input required maxlength="255" type="password" name="pwdc" id="pwdc"></input>
  105.         </td>
  106.     </tr>
  107.     <tr>
  108.         <td>
  109.             <label for="accept">I accept the <br>tems of usage <br>or so...</label>
  110.         </td>
  111.         <td>
  112.             <input required type="checkbox" id="accept"></input>
  113.         </td>
  114.     </tr>
  115.     <tr>
  116.         <td>
  117.         </td>
  118.         <td>
  119.             <input type="submit"></input>
  120.             <input type="reset"></input>
  121.         </td>
  122.     </tr>
  123. </table>
  124. </form>
  125. </div>
  126. <?php
  127.  $aktuell = 2;
  128.  include 'footer.php';
  129. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement