Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if( isset($_SESSION['user']) ){
- header("Location: /commerce");
- }
- require 'db.php';
- $username = '';
- $fname = '';
- $lname = '';
- $email = '';
- $password = '';
- $cpassword = '';
- $message = '';
- if($_SERVER['REQUEST_METHOD'] == 'POST') {
- $fname = $_POST["fname"];
- $lname = $_POST["lname"];
- $username = $_POST["username"];
- $password = $_POST["passwd"];
- $cpassword = $_POST["cpasswd"];
- $email = $_POST["email"];
- if(!empty($username) && !empty($password) && !empty($cpassword) && !empty($email) && !empty($fname) ){
- // Enter the new user in the database
- $sql = "INSERT INTO users (username, email, password, fname, lname) VALUES (:username,:email, :password, :fname, :lname)";
- $stmt = $conn->prepare($sql);
- $stmt->bindParam(':username', $username);
- $stmt->bindParam(':email', $email);
- $stmt->bindParam(':password', password_hash($password, PASSWORD_BCRYPT));
- $stmt->bindParam(':fname', $fname);
- $stmt->bindParam(':lname',$lname);
- if( $stmt->execute() ) {
- $message = 'Successfully created new user';
- }
- else{
- $message = 'Sorry there must have been an issue creating your account';
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Inscription</title>
- <link rel="stylesheet" href="layout/css/bootstrap.min.css">
- <link rel="stylesheet" href="layout/css/main.css">
- </head>
- <form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST">
- <table>
- <tr>
- <th> nom:</th>
- <td> <input type="text" name="fname" ></td>
- </tr>
- <tr>
- <th>prenom:</th>
- <td><input type="text" name="lname" ></td>
- </tr>
- <tr>
- <th>nom d'utilisateur:</th>
- <td><input type="text" name="username" ></td>
- </tr>
- <tr>
- <th>mot de passe:</th>
- <td><input type="password" name="passwd" ></td>
- </tr>
- <tr>
- <th>confirmer votre mot de passe:</th>
- <td><input type="password" name="cpasswd" ></td>
- </tr>
- <tr>
- <th>adresse email:</th>
- <td><input type="email" name="email"></td>
- </tr>
- <tr>
- <th>telephone:</th>
- <td><input type="number" name="" ></td>
- </tr>
- <tr>
- <th></th>
- <td><input type="submit" value="submit" ></td>
- </tr>
- </table>
- <?php
- if ($message != null)
- echo '<br>' . $message . '<br>';
- ?>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement