Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $mysqli = new mysqli('ip', 'user', 'pass', 'dbname');
- $post = filter_input_array(INPUT_POST);
- if (isset($post)) {
- $skills = $mysqli->real_escape_string($post['skills']);
- if (isset($post['email'])) {
- $temp_email= $post['email'];
- $sql = $mysqli->query("SELECT email FROM users WHERE email='$temp_email'");
- if ($sql->num_rows > 0) {
- $msg = "email already exists!";
- } else {
- $email = $temp_email;
- }
- } else {
- $msg = "Please enter your email!";
- }
- if (isset($post['username'])) {
- $temp_username= $post['username'];
- $sql = $mysqli->query("SELECT username FROM users WHERE username='$temp_username'");
- if ($sql->num_rows > 0) {
- $msg = "Username already exists!";
- } else {
- $username = $temp_username;
- }
- } else {
- $msg = "Please enter your username!";
- }
- if (isset($post['password'])) {
- if ($post['password'] === $post['confirmpassword']) {
- $password = password_hash($password, PASSWORD_BCRYPT); //hash and bcrypt adds a level of security for the password so once it's saved into the database it will be saved as something else
- } else {
- $msg = "Two passwords do not match!";
- }
- } else {
- $msg = "Please enter your password!";
- }
- if(isset($post['captcha'])) {
- if ($post['captcha'] === $_SESSION['captcha']) {
- } else {
- $msg = "The captcha is not correct";
- }
- } else {
- $msg = "Please enter the captcha";
- }
- if(isset($email) && isset($username) && isset($password)) {
- //if the query is successful, redirect to emailvalidation.php page
- $mysqli->query("INSERT INTO users (username,email,password,skills,active,activationCode)
- VALUES ('$username', '$email', '$password','$skills', '0', '$activationCodeString');
- ");
- // $mysqli->query($sql);
- }
Add Comment
Please, Sign In to add comment