Jump to content

PHP login help


iJoseph

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.