Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'db_connect.php';
- //if receives data from insert form, run function
- if(isset($_POST['insert_data']) )
- {
- $refno_usr = uniqid();
- $username = SQLite3::escapeString($_POST['username']);
- $password = SQLite3::escapeString($_POST['password']);
- $cpassword = SQLite3::escapeString($_POST['cpassword']);
- $fullname = SQLite3::escapeString($_POST['fullname']);
- $access = SQLite3::escapeString($_POST['access']);
- //check if confirm password equals password
- if($password != $cpassword) {
- echo $db->lastErrorMsg();
- } else {
- //hash and salt
- $hash = password_hash($password, PASSWORD_BCRYPT);
- }
- $sql =<<<EOF
- INSERT INTO userlist (refno_usr, user_name, user_password, full_name, admin_user)
- VALUES ('$refno_usr', '$username', '$hash', '$fullname', '$access');
- EOF;
- //Executes query
- $ret = $db->query($sql);
- //outputs error or success message
- if(!$ret)
- {
- echo $db->lastErrorMsg();
- } else {
- echo "Records Inserted successfully\n";
- }
- //Closes connection
- $db->close();
- unset($db);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement