Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'header.php';
- include 'database_login.php';
- $fields = ["first", "last", "mail", "uname", "age", "pwd", "pwdc"];
- $full = true;
- $errors = [];
- foreach($fields as $f){
- if(!isset($_POST[$f])){
- $full = false;
- }
- }
- if($full){
- /*
- *
- * REGISTERING
- *
- */
- $sql = "SELECT * FROM user WHERE mail=\"".$_POST['mail']."\"";
- $result = mysqli_query($conn_l, $sql);
- $num = mysqli_num_rows($result);
- if($num > 0){
- array_push($errors, "Email is already in use: ".$_POST['mail']);
- }
- $sql = "SELECT * FROM user WHERE uname=\"".$_POST['uname']."\"";
- $result = mysqli_query($conn_l, $sql);
- $num = mysqli_num_rows($result);
- if($num > 0){
- array_push($errors, "Username is already taken:".$_POST['uname']);
- }
- if($_POST['pwd'] != $_POST['pwdc']){
- array_push($errors, "The passwords don't match!");
- }
- if(empty($errors)){
- $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'])."\")";
- $result = mysqli_query($conn_l, $sql);
- }
- }
- ?>
- <div id="div_breite" class="inhalt">
- <h4 style="text-align:left;">Register!</h4>
- <?php
- if(!empty($errors)){
- foreach ($errors as $e){
- echo "<b>".$e."</b><br>";
- }
- }
- ?>
- <form action="register.php" method="POST">
- <table>
- <tr>
- <td>
- <label for="first">First name:</label>
- </td>
- <td>
- <input required maxlength="255" type="text" name="first" id="first"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="last">Last name:</label>
- </td>
- <td>
- <input required maxlength="255" type="text" name="last" id="last"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="mail">Email:</label>
- </td>
- <td>
- <input required maxlength="255" type="email" name="mail" id="mail"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="uname">Username:</label>
- </td>
- <td>
- <input required maxlength="32" type="text" name="uname" id="uname"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="uname">Age:</label>
- </td>
- <td>
- <input required min="10" max="100" type="number" name="age" id="age"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="pwd">Password:</label>
- </td>
- <td>
- <input required maxlength="255" type="password" name="pwd" id="pwd"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="pwdc">Repeat <br>Password:</label>
- </td>
- <td>
- <input required maxlength="255" type="password" name="pwdc" id="pwdc"></input>
- </td>
- </tr>
- <tr>
- <td>
- <label for="accept">I accept the <br>tems of usage <br>or so...</label>
- </td>
- <td>
- <input required type="checkbox" id="accept"></input>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- <input type="submit"></input>
- <input type="reset"></input>
- </td>
- </tr>
- </table>
- </form>
- </div>
- <?php
- $aktuell = 2;
- include 'footer.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement