Jump to content

Recommended Posts

I have made some code to log into a website.

However, when the code runs there appears to be no output. Here is the code:

<?php
$username = $_POST['reg_username'];
$password = $_POST['reg_password'];

include "database.php";

$row = mysql_query("SELECT * FROM users WHERE username='$username' && password='$password'");

while($relult = mysql_fetch_array($row)) {
if($username == $result['username']){
echo "Logged in.";
}
else {
echo "Not logged in.";
} }
?>

 

When the file runs, the page is blank.

I have not been programming with PHP very long (I'm only 13) and I would like it if sombody could help me, Thanks :D

Link to comment
https://forums.phpfreaks.com/topic/200816-php-login-help/
Share on other sites

Try for somthing like this:

<?php
$username = $_POST['reg_username'];
$password = $_POST['reg_password'];

include "database.php";

$result = mysql_query("SELECT username, password FROM users WHERE username='".$username."' AND password= '".$password."'") or die (mysql_error());
$row = mysql_fetch_assoc($rersult) 
if($username == $row['username'] && $password == $row['password']){
echo "Logged in.";
}
else {
echo "Not logged in.";
} 
?>

The reason that you are getting a blank screen is because you don't have error reporting set up properly on the server.

Link to comment
https://forums.phpfreaks.com/topic/200816-php-login-help/#findComment-1053682
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.