Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['button'])){
- include_once 'db.inc.php' ; //ou on a la db pour utiliser $conn
- // $firstname = mysqli_real_escape_string($conn, $_POST['first']); // to protect from sql injection attack
- $firstname = $_POST['first'];
- $lastname = $_POST['last'];
- $email = $_POST['email'];
- $uid = $_POST['uid'];
- $pwd = $_POST['pwd'] ;
- if (empty($firstname) || empty($lastname) || empty($email) || empty($uid) || empty($pwd)){
- header("Location: ../home.php?signup=empty") ;
- exit() ;
- }else{
- $sql = "insert into users (firstname,lastname,email,uid,pwd) values(?,?,?,?,?);";
- $stmt = mysqli_stmt_init($conn) ;
- if(!mysqli_stmt_prepare($stmt, $sql)) {
- echo "operation failed " ;
- }else {
- mysqli_stmt_bind_param($stmt,"sssss",$firstname,$lastname,$email,$uid,$pwd);
- mysqli_stmt_execute($stmt) ;
- header("Location: ../home.php?signup=success") ;
- }
- /*
- // mysqli_query :you send the cmd request and returne ressources if success else returns false
- $result = mysqli_query ( $conn, $sql ) ;
- //for test of connection
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- header("Location: ../home.php?signup=success") ;
- */
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement