Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( empty( $_POST ) ){
- ?>
- <form name='registration' action='pdo1.php' method='POST'/>
- <input type="text" name="user_name">
- <input type="password" name="password">
- <input type="text" name="email">
- <button type="submit">Submit</button>
- </form>
- <?php
- } else {
- // host, myU, myP and myDB are all correct
- $db_user = 'myU';
- $db_pass = 'myP';
- $db = new PDO( 'mysql:host=localhost;dbname=myDB', $db_user, $db_pass );
- $sql = "INSERT INTO users ( user_name, password, email ) VALUES ( :username, :password, :email )";
- $query = $db->prepare( $sql );
- $result = $query->execute( array( ':username'=>$username, ':password'=>$password, ':email'=>$email ) );
- if($result) {
- echo "Worked!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement