Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="en">
- <head>
- <title>Registration</title>
- <link rel="stylesheet" type="text/css" href="css/style.css">
- <link href='http://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css'>
- </head>
- <body>
- <?php
- if (empty( $_POST ) ) {
- ?>
- <div class="register">
- <h1>Registration</h1>
- <form name="registration" action="register.php" method="POST">
- <label for 'username'>Username: </label>
- <br>
- <input type="text" name="username"/>
- <br>
- <label for 'password'>Password: </label>
- <br>
- <input type="password" name="password"/>
- <br>
- <label for 'first_name'>First name: </label>
- <br>
- <input type="text" name="first_name"/>
- <br>
- <label for 'surname'>Surname: </label>
- <br>
- <input type="text" name="surname"/>
- <br>
- <label for 'address'>Address: </label>
- <br>
- <input type="text" name="address"/>
- <br>
- <label for 'email'>Email: </label>
- <br>
- <input type="text" name="email"/>
- <br><br>
- <button type="submit">Submit</button>
- </form>
- </div>
- <?php
- } else {
- $user = 'root';
- $pass = '';
- $db = new PDO( 'mysql:host=localhost;dbname=users', $user, $pass );
- $form = $_POST;
- $username = $form['username'];
- $password = $form['password'];
- $first_name = $form['first_name'];
- $surname = $form['surname'];
- $address = $form['address'];
- $email = $form['email'];
- $sql = "INSERT INTO users ( username, password, first_name, surname, address, email )
- VALUES ( :username, :password, :first_name, :surname, :address, :email )";
- $query = $db->prepare( $sql );
- $query->execute( array( ':username'=>$username, ':password'=>$password, ':first_name'=>$first_name, ':surname'=>$surname, ':address'=>$address, ':email'=>$email ) );
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement