Signup script not inserting users anymore into table, nor allowing logins Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Insert results of a stored procedure into a temporary tableORA-24374 error in php scriptORA-00917 in php scriptPHP login and get user informationInsert into a MySQL table or update if existsphp script echoing part of the php instead of what intendedmysqli_stmt expected queryAllow user to add data to his sql table row and edit itpage doesn't run the mysqli_stmt_executeinsert data into multiple columns in a database using mysqli prepared statements
`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY
Raising a bilingual kid. When should we introduce the majority language?
Variable does not exist: sObjectType (Task.sObjectType)
How can I wire a 9-position switch so that each position turns on one more LED than the one before?
TV series episode where humans nuke aliens before decrypting their message that states they come in peace
Preserving file and folder permissions with rsync
Specify the range of GridLines
Protagonist's race is hidden - should I reveal it?
When speaking, how do you change your mind mid-sentence?
Why is arima in R one time step off?
What is the purpose of the side handle on a hand ("eggbeater") drill?
How to compute a Jacobian using polar coordinates?
Is it appropriate to mention a relatable company blog post when you're asked about the company?
Is a self contained air-bullet cartridge feasible?
All ASCII characters with a given bit count
Israeli soda type drink
France's Public Holidays' Puzzle
/bin/ls sorts differently than just ls
Not within Jobscope - Aggravated injury
What was Apollo 13's "Little Jolt" after MECO?
A journey... into the MIND
What is a 'Key' in computer science?
How was Lagrange appointed professor of mathematics so early?
How long can a nation maintain a technological edge over the rest of the world?
Signup script not inserting users anymore into table, nor allowing logins
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Insert results of a stored procedure into a temporary tableORA-24374 error in php scriptORA-00917 in php scriptPHP login and get user informationInsert into a MySQL table or update if existsphp script echoing part of the php instead of what intendedmysqli_stmt expected queryAllow user to add data to his sql table row and edit itpage doesn't run the mysqli_stmt_executeinsert data into multiple columns in a database using mysqli prepared statements
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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'])) 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
php mysql sql
|
show 3 more comments
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'])) 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
php mysql sql
How did you setfldUserLevelin your database, because if it's set to not being NULL you'll have an issue with your sign-in : you never setfldUserLevelin yourINSERTstatement. Don't you have some SQL errors displayed ?
– Romain B.
Mar 22 at 15:07
Hi @RomainB. that's exactly what it is, I think, as I just manually went in to the table for testing to existing members and set those as members myself, how would I add this into my signup statement about saying insert asMemberinfldUserLevel, I think that's why it's not allowing me to sign up anyone
– qwpozxmn
Mar 22 at 15:08
1
You should check whethermysqli_stmt_executethrows any error throughmysqli_stmt_error- this will help you to find such errors on your own
– Nico Haase
Mar 22 at 15:09
You can modify your query to"INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers,fldUserLevel) VALUES (?, ?, ?, ?);"or set a default value on your column as everyone seems to be a Member by default : dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
– Romain B.
Mar 22 at 15:11
@NicoHaase where should I paste thatmysqli_stmt_error?
– qwpozxmn
Mar 22 at 15:11
|
show 3 more comments
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'])) 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
php mysql sql
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'])) 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
php mysql sql
php mysql sql
edited Mar 22 at 15:07
qwpozxmn
asked Mar 22 at 14:59
qwpozxmnqwpozxmn
278
278
How did you setfldUserLevelin your database, because if it's set to not being NULL you'll have an issue with your sign-in : you never setfldUserLevelin yourINSERTstatement. Don't you have some SQL errors displayed ?
– Romain B.
Mar 22 at 15:07
Hi @RomainB. that's exactly what it is, I think, as I just manually went in to the table for testing to existing members and set those as members myself, how would I add this into my signup statement about saying insert asMemberinfldUserLevel, I think that's why it's not allowing me to sign up anyone
– qwpozxmn
Mar 22 at 15:08
1
You should check whethermysqli_stmt_executethrows any error throughmysqli_stmt_error- this will help you to find such errors on your own
– Nico Haase
Mar 22 at 15:09
You can modify your query to"INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers,fldUserLevel) VALUES (?, ?, ?, ?);"or set a default value on your column as everyone seems to be a Member by default : dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
– Romain B.
Mar 22 at 15:11
@NicoHaase where should I paste thatmysqli_stmt_error?
– qwpozxmn
Mar 22 at 15:11
|
show 3 more comments
How did you setfldUserLevelin your database, because if it's set to not being NULL you'll have an issue with your sign-in : you never setfldUserLevelin yourINSERTstatement. Don't you have some SQL errors displayed ?
– Romain B.
Mar 22 at 15:07
Hi @RomainB. that's exactly what it is, I think, as I just manually went in to the table for testing to existing members and set those as members myself, how would I add this into my signup statement about saying insert asMemberinfldUserLevel, I think that's why it's not allowing me to sign up anyone
– qwpozxmn
Mar 22 at 15:08
1
You should check whethermysqli_stmt_executethrows any error throughmysqli_stmt_error- this will help you to find such errors on your own
– Nico Haase
Mar 22 at 15:09
You can modify your query to"INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers,fldUserLevel) VALUES (?, ?, ?, ?);"or set a default value on your column as everyone seems to be a Member by default : dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
– Romain B.
Mar 22 at 15:11
@NicoHaase where should I paste thatmysqli_stmt_error?
– qwpozxmn
Mar 22 at 15:11
How did you set
fldUserLevel in your database, because if it's set to not being NULL you'll have an issue with your sign-in : you never set fldUserLevel in your INSERT statement. Don't you have some SQL errors displayed ?– Romain B.
Mar 22 at 15:07
How did you set
fldUserLevel in your database, because if it's set to not being NULL you'll have an issue with your sign-in : you never set fldUserLevel in your INSERT statement. Don't you have some SQL errors displayed ?– Romain B.
Mar 22 at 15:07
Hi @RomainB. that's exactly what it is, I think, as I just manually went in to the table for testing to existing members and set those as members myself, how would I add this into my signup statement about saying insert as
Member in fldUserLevel, I think that's why it's not allowing me to sign up anyone– qwpozxmn
Mar 22 at 15:08
Hi @RomainB. that's exactly what it is, I think, as I just manually went in to the table for testing to existing members and set those as members myself, how would I add this into my signup statement about saying insert as
Member in fldUserLevel, I think that's why it's not allowing me to sign up anyone– qwpozxmn
Mar 22 at 15:08
1
1
You should check whether
mysqli_stmt_execute throws any error through mysqli_stmt_error - this will help you to find such errors on your own– Nico Haase
Mar 22 at 15:09
You should check whether
mysqli_stmt_execute throws any error through mysqli_stmt_error - this will help you to find such errors on your own– Nico Haase
Mar 22 at 15:09
You can modify your query to
"INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers,fldUserLevel) VALUES (?, ?, ?, ?);" or set a default value on your column as everyone seems to be a Member by default : dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html– Romain B.
Mar 22 at 15:11
You can modify your query to
"INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers,fldUserLevel) VALUES (?, ?, ?, ?);" or set a default value on your column as everyone seems to be a Member by default : dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html– Romain B.
Mar 22 at 15:11
@NicoHaase where should I paste that
mysqli_stmt_error ?– qwpozxmn
Mar 22 at 15:11
@NicoHaase where should I paste that
mysqli_stmt_error ?– qwpozxmn
Mar 22 at 15:11
|
show 3 more comments
1 Answer
1
active
oldest
votes
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);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302426%2fsignup-script-not-inserting-users-anymore-into-table-nor-allowing-logins%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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);
add a comment |
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);
add a comment |
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);
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);
answered Mar 22 at 15:24
K.HaydockK.Haydock
15211
15211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302426%2fsignup-script-not-inserting-users-anymore-into-table-nor-allowing-logins%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How did you set
fldUserLevelin your database, because if it's set to not being NULL you'll have an issue with your sign-in : you never setfldUserLevelin yourINSERTstatement. Don't you have some SQL errors displayed ?– Romain B.
Mar 22 at 15:07
Hi @RomainB. that's exactly what it is, I think, as I just manually went in to the table for testing to existing members and set those as members myself, how would I add this into my signup statement about saying insert as
MemberinfldUserLevel, I think that's why it's not allowing me to sign up anyone– qwpozxmn
Mar 22 at 15:08
1
You should check whether
mysqli_stmt_executethrows any error throughmysqli_stmt_error- this will help you to find such errors on your own– Nico Haase
Mar 22 at 15:09
You can modify your query to
"INSERT INTO tblUsers (uidUsers, emailUsers, pwdUsers,fldUserLevel) VALUES (?, ?, ?, ?);"or set a default value on your column as everyone seems to be a Member by default : dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html– Romain B.
Mar 22 at 15:11
@NicoHaase where should I paste that
mysqli_stmt_error?– qwpozxmn
Mar 22 at 15:11