Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Registration with database-->
- <?php
- $user = 'root';
- $pass = '';
- $db = new PDO( 'mysql:host=localhost;dbname=reguser', $user, $pass );
- ?>
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <title>Registro de pessoas</title>
- <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
- <style>
- .jumbotron {
- margin-left: auto;
- margin-right: auto;
- width: 50%;
- padding: 0 10%;
- }
- </style>
- </head>
- <body>
- <div class="jumbotron">
- <h1> Registro </h1>
- <?php
- if(empty($_POST)){
- ?>
- <form name="registration" action="registration.php" method="POST">
- <div class="form-group">
- <label for="nome">UserName: </label>
- <input type="text" name="username" class="form-control" id="exampleInputEmail1" placeholder="UserName">
- </div>
- <div class="form-group">
- <label for="senha">Password</label>
- <input type="password" name="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
- </div>
- <div class="form-group">
- <label for="first_name">Firt name: </label>
- <input type="text" name="first_name" class="form-control" id="exampleInputPassword1" placeholder="Firt name">
- </div>
- <div class="form-group">
- <label for="surname">Surname: </label>
- <input type="text" name="surname" class="form-control" id="exampleInputPassword1" placeholder="Surname">
- </div>
- <div class="form-group">
- <label for="address">Address: </label>
- <input type="text" name="address" class="form-control" id="exampleInputPassword1" placeholder="Address">
- </div>
- <div class="form-group">
- <label for="email">E-mail: </label>
- <input type="text" name="email" class="form-control" id="exampleInputPassword1" placeholder="E-mail">
- </div>
- <button type="submit" class="btn btn-default btn-primary">Submit</button>
- </form>
- <?php
- $form = $_POST;
- $username = $form['username'];
- $password = $form['password'];
- $first_name = $form['first_name'];
- $surname = $form['surname'];
- $address = $form['address'];
- $email = $form['email'];
- echo $form;
- $sql = "INSERT INTO usuarios (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 ) );
- $result = $query->execute( array( ':username'=>$username, ':password'=>$password, ':first_name'=>$first_name, ':surname'=>$surname, ':address'=>$address, ':email'=>$email ) );
- }else{
- if ( $result ){
- echo "<p>Thank you. You have been registered</p>";
- } else {
- echo "<p>Sorry, there has been a problem inserting your details. Please contact admin.</p>";
- }
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement