PHP MYSQL Cant get user data to pull from database, only id and name [closed]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I cant seem to get any of my users other information pulled from the database other than their username and ID and im not understanding why, heres my code trying to call it from session.
// Now we check if the data was submitted, isset will check if the data exists.
if ( !isset($_POST['username'], $_POST['password']) ) {
// Could not get the data that should have been sent.
die ('Username and/or password does not exist!');
}
// Prepare our SQL
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
// Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
$stmt->bind_param('s', $_POST['username']);
$stmt->execute();
$stmt->store_result();
// Store the result so we can check if the account exists in the database.
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $password);
$stmt->fetch();
// Account exists, now we verify the password.
if (password_verify($_POST['password'], $password)) {
// Verification success! User has loggedin!
$_SESSION['loggedin'] = TRUE;
$_SESSION['username'] = $_POST['username'];
$_SESSION['id'] = $id;
$_SESSION['title'] = $title;
$_SESSION['website'] = $website;
$_SESSION['youtube'] = $youtube;
$_SESSION['facebook'] = $facebook;
$_SESSION['paypalemail'] = $paypalemail;
echo 'Welcome ' . $_SESSION['username'] . '!';
echo 'Welcome ' . $_SESSION['title'] . '!';
echo'<a href="/profile.php">My Profile </a>';
} else {
echo 'Incorrect username and/or password!';
}
} else {
echo 'Incorrect username and/or password!';
}
$stmt->close();
} else {
echo 'Could not prepare statement!';
}
?>
php mysql database
closed as off-topic by Tetsujin, fixer1234, Toto, music2myear, bertieb Jan 30 at 19:30
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about computer hardware or software, within the scope defined in the help center." – Tetsujin, fixer1234, music2myear, bertieb
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I cant seem to get any of my users other information pulled from the database other than their username and ID and im not understanding why, heres my code trying to call it from session.
// Now we check if the data was submitted, isset will check if the data exists.
if ( !isset($_POST['username'], $_POST['password']) ) {
// Could not get the data that should have been sent.
die ('Username and/or password does not exist!');
}
// Prepare our SQL
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
// Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
$stmt->bind_param('s', $_POST['username']);
$stmt->execute();
$stmt->store_result();
// Store the result so we can check if the account exists in the database.
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $password);
$stmt->fetch();
// Account exists, now we verify the password.
if (password_verify($_POST['password'], $password)) {
// Verification success! User has loggedin!
$_SESSION['loggedin'] = TRUE;
$_SESSION['username'] = $_POST['username'];
$_SESSION['id'] = $id;
$_SESSION['title'] = $title;
$_SESSION['website'] = $website;
$_SESSION['youtube'] = $youtube;
$_SESSION['facebook'] = $facebook;
$_SESSION['paypalemail'] = $paypalemail;
echo 'Welcome ' . $_SESSION['username'] . '!';
echo 'Welcome ' . $_SESSION['title'] . '!';
echo'<a href="/profile.php">My Profile </a>';
} else {
echo 'Incorrect username and/or password!';
}
} else {
echo 'Incorrect username and/or password!';
}
$stmt->close();
} else {
echo 'Could not prepare statement!';
}
?>
php mysql database
closed as off-topic by Tetsujin, fixer1234, Toto, music2myear, bertieb Jan 30 at 19:30
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about computer hardware or software, within the scope defined in the help center." – Tetsujin, fixer1234, music2myear, bertieb
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I cant seem to get any of my users other information pulled from the database other than their username and ID and im not understanding why, heres my code trying to call it from session.
// Now we check if the data was submitted, isset will check if the data exists.
if ( !isset($_POST['username'], $_POST['password']) ) {
// Could not get the data that should have been sent.
die ('Username and/or password does not exist!');
}
// Prepare our SQL
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
// Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
$stmt->bind_param('s', $_POST['username']);
$stmt->execute();
$stmt->store_result();
// Store the result so we can check if the account exists in the database.
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $password);
$stmt->fetch();
// Account exists, now we verify the password.
if (password_verify($_POST['password'], $password)) {
// Verification success! User has loggedin!
$_SESSION['loggedin'] = TRUE;
$_SESSION['username'] = $_POST['username'];
$_SESSION['id'] = $id;
$_SESSION['title'] = $title;
$_SESSION['website'] = $website;
$_SESSION['youtube'] = $youtube;
$_SESSION['facebook'] = $facebook;
$_SESSION['paypalemail'] = $paypalemail;
echo 'Welcome ' . $_SESSION['username'] . '!';
echo 'Welcome ' . $_SESSION['title'] . '!';
echo'<a href="/profile.php">My Profile </a>';
} else {
echo 'Incorrect username and/or password!';
}
} else {
echo 'Incorrect username and/or password!';
}
$stmt->close();
} else {
echo 'Could not prepare statement!';
}
?>
php mysql database
I cant seem to get any of my users other information pulled from the database other than their username and ID and im not understanding why, heres my code trying to call it from session.
// Now we check if the data was submitted, isset will check if the data exists.
if ( !isset($_POST['username'], $_POST['password']) ) {
// Could not get the data that should have been sent.
die ('Username and/or password does not exist!');
}
// Prepare our SQL
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
// Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
$stmt->bind_param('s', $_POST['username']);
$stmt->execute();
$stmt->store_result();
// Store the result so we can check if the account exists in the database.
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $password);
$stmt->fetch();
// Account exists, now we verify the password.
if (password_verify($_POST['password'], $password)) {
// Verification success! User has loggedin!
$_SESSION['loggedin'] = TRUE;
$_SESSION['username'] = $_POST['username'];
$_SESSION['id'] = $id;
$_SESSION['title'] = $title;
$_SESSION['website'] = $website;
$_SESSION['youtube'] = $youtube;
$_SESSION['facebook'] = $facebook;
$_SESSION['paypalemail'] = $paypalemail;
echo 'Welcome ' . $_SESSION['username'] . '!';
echo 'Welcome ' . $_SESSION['title'] . '!';
echo'<a href="/profile.php">My Profile </a>';
} else {
echo 'Incorrect username and/or password!';
}
} else {
echo 'Incorrect username and/or password!';
}
$stmt->close();
} else {
echo 'Could not prepare statement!';
}
?>
php mysql database
php mysql database
asked Jan 29 at 9:19
Sebastian ShearerSebastian Shearer
31
31
closed as off-topic by Tetsujin, fixer1234, Toto, music2myear, bertieb Jan 30 at 19:30
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about computer hardware or software, within the scope defined in the help center." – Tetsujin, fixer1234, music2myear, bertieb
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Tetsujin, fixer1234, Toto, music2myear, bertieb Jan 30 at 19:30
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about computer hardware or software, within the scope defined in the help center." – Tetsujin, fixer1234, music2myear, bertieb
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Where are the variables $title
,$website
,$youtube
,$facebook
,$paypalemail
coming from? If they are stored in the accounts
table with the same column names as the variable names you used you need to retrieve them along with the id and password.
Change
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
to
if ($stmt = $con->prepare('SELECT
`id`,
`password`,
`title`,
`website`,
`youtube`,
`facebook`,
`paypalemail`
FROM accounts WHERE username = ?')) {
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Where are the variables $title
,$website
,$youtube
,$facebook
,$paypalemail
coming from? If they are stored in the accounts
table with the same column names as the variable names you used you need to retrieve them along with the id and password.
Change
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
to
if ($stmt = $con->prepare('SELECT
`id`,
`password`,
`title`,
`website`,
`youtube`,
`facebook`,
`paypalemail`
FROM accounts WHERE username = ?')) {
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
add a comment |
Where are the variables $title
,$website
,$youtube
,$facebook
,$paypalemail
coming from? If they are stored in the accounts
table with the same column names as the variable names you used you need to retrieve them along with the id and password.
Change
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
to
if ($stmt = $con->prepare('SELECT
`id`,
`password`,
`title`,
`website`,
`youtube`,
`facebook`,
`paypalemail`
FROM accounts WHERE username = ?')) {
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
add a comment |
Where are the variables $title
,$website
,$youtube
,$facebook
,$paypalemail
coming from? If they are stored in the accounts
table with the same column names as the variable names you used you need to retrieve them along with the id and password.
Change
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
to
if ($stmt = $con->prepare('SELECT
`id`,
`password`,
`title`,
`website`,
`youtube`,
`facebook`,
`paypalemail`
FROM accounts WHERE username = ?')) {
Where are the variables $title
,$website
,$youtube
,$facebook
,$paypalemail
coming from? If they are stored in the accounts
table with the same column names as the variable names you used you need to retrieve them along with the id and password.
Change
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
to
if ($stmt = $con->prepare('SELECT
`id`,
`password`,
`title`,
`website`,
`youtube`,
`facebook`,
`paypalemail`
FROM accounts WHERE username = ?')) {
answered Jan 29 at 13:06
DaveDave
21227
21227
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
add a comment |
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir!
– Sebastian Shearer
Jan 29 at 22:21
add a comment |