Advertisement
Skorpius

Insert Statement Structure (Named Params)

Jun 24th, 2022 (edited)
1,368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1.                /* Using named parameters */
  2.                //Initial Profile Image until default name is inserted
  3.                $profileimg = "1.jpg";
  4.                //Default text for bio
  5.                $bio = 'Enter something about yourself.';
  6.  
  7.                $sql = "INSERT INTO users (firstname,lastname,username,gender,email,password,profile_img,bio) VALUES (:fname,:lname,:username,:gender,:email,:password,:profileimg,:bio)";
  8.  
  9.                $stmt = $pdo->prepare($sql);
  10.                $stmt->bindParam(':fname',$fname);
  11.                $stmt->bindParam(':lname',$lname);
  12.                $stmt->bindParam(':username',$uname);
  13.                $stmt->bindParam(':gender',$gender);
  14.                $stmt->bindParam(':email',$email);
  15.                $stmt->bindParam(':password',$hash);
  16.                $stmt->bindParam(':profileimg',$profileimg);
  17.                $stmt->bindParam(':bio',$bio);
  18.                $stmt->execute();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement