in Education by
Registering members and allowing them to login (updating tables etc) all worked fine up until I made this change recently. Which essentially said, if this person logs in check if they are member or admin and show them a different page depending on what they are). I manually went into the table and set existing users as a 'member' apart from 1 person who was 'admin'. Now when I try to sign a user up it doesn't insert into the tblUsers anymore. The change I made is below: <?php if ($_SESSION['fldUserLevel'] == 'Member'){ ?> // PAGE DETAILS <?php } ?> ^^^ This would show top half of page and then for admin who would see the bottom half of the page: <?php if ($_SESSION['fldUserLevel'] == 'Admin'){ ?> // PAGE DETAILS <?php } ?> Since doing this when I sign a user up, the details no longer go into the table, can someone suggest why? Or do I need a script that says all people who sign up, make the UserLevel 'Member'? Code for signing up: <?php if (isset($_POST['signup-submit'])) { require 'dbh.inc.php'; $username = $_POST['uid']; $email = $_POST['mail']; $password = $_POST['pwd']; $passwordRepeat = $_POST['pwd-repeat']; // check for any empty inputs. if (empty($username) || empty($email) || empty($password) || empty($passwordRepeat)) { header("Location: ../signup.php?error=emptyfields&uid=".$username."&mail=".$email); exit(); } // check for an invalid username AND invalid e-mail. else if (!preg_match("/^[a-zA-Z0-9]*$/", $username) && !filter_var($email, FILTER_VALIDATE_EMAIL)) { header("Location: ../signup.php?error=invaliduidmail"); exit(); } // check for an invalid username. In this case ONLY letters and numbers. else if (!preg_match("/^[a-zA-Z0-9]*$/", $username)) { header("Location: ../signup.php?error=invaliduid&mail=".$email); exit(); } // check for an invalid e-mail. else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { header("Location: ../signup.php?error=invalidmail&uid=".$username); exit(); } // check if the repeated password is NOT the same. else if ($password !== $passwordRepeat) { header("Location: ../signup.php?error=passwordcheck&uid=".$username."&mail=".$email); exit(); } else { // include another error handler here that checks whether or the username is already taken. We HAVE to do this using prepared statements because it is safer! $sql = "SELECT uidUsers FROM tblUsers WHERE uidUsers=?;"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { header("Location: ../signup.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "s", $username); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); $resultCount = mysqli_stmt_num_rows($stmt); mysqli_stmt_close($stmt); if ($resultCount > 0) { header("Location: ../signup.php?error=usertaken&mail=".$email); exit(); } else { $sql = "INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers) VALUES (?, ?, ?);"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { header("Location: ../signup.php?error=sqlerror"); exit(); } else { $hashedPwd = password_hash($password, PASSWORD_DEFAULT); mysqli_stmt_bind_param($stmt, "sss", $username, $email, $hashedPwd); mysqli_stmt_execute($stmt); header("Location: ../signup.php?signup=success"); exit(); } } } } mysqli_stmt_close($stmt); mysqli_close($conn); } else { header("Location: ../signup.php"); exit(); } Screenshot of webpage saying successful signup: Signup Successful Message Screenshot of table, which shows no entry of Kayz: Screenshot of phpMyAdmin JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Ensure that you have actually set a variable name giving "Member"; or "Admin";, however I would suggest that as Romain.B suggests to read that document on setting default values. $member = "Member"; or "Admin"; Then your query should be: $sql = "INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers, fldUserLevel) VALUES (?, ?, ?, ?);"; Further down you need to include your new variable of $member: mysqli_stmt_bind_param($stmt, "ssss", $username, $email, $hashedPwd, $member);

Related questions

0 votes
    Symfony version: 3.1.3 Due to development reason suddenly my app giving the following error and I believe ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I have multiple tables like make, model and year etc and using joins. I would like to search from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I have multiple tables like make, model and year etc and using joins. I would like to search from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Hello! Like in title. There is code example. Result is: Nulla eu aliquet sapien. Sed in sagittis ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Hello! Like in title. There is code example. Result is: Nulla eu aliquet sapien. Sed in sagittis ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I do know that PDO does not support multiple queries getting executed in one statement. I've been Googleing ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    why it's not working.. i want to update my table in database this is my code. for ($i=0; ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I am looking to get row count to check if same email is already in database or not. i have tried ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm getting an error with this function: Controller $data['carSubwoofers'] = $this->db->get_where(" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
+1 vote
    Consortium blockchain has a predefined set of nodes allowing the users to write the data. (1)False (2)True...
asked Oct 13, 2020 in Technology by JackTerrance
0 votes
    DROP TYPE Position; CREATE OR REPLACE TYPE Position AS OBJECT (longitude NUMBER(11,7), lattitude NUMBER(11, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I am trying to input text into the text box in 'www.google.com' and though it says the text ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    What option would you specify when inserting code in a web page? script type="____" 1. text/language 2. JavaScript/text 3. text/JavaScript...
asked Feb 23, 2021 in Technology by JackTerrance
+1 vote
    What option would you specify when inserting code in a web page? script type="____" a)text/language b)JavaScript/text c)text/JavaScript...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    I am using VBA in most of my office 365 applications for many years now. Last week an error ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
...