Jump to content

Recommended Posts

<?php
session_start();
include("dbconnect.php");
$username = $_POST['UserName'];
$postpassword = $_POST['UserPassword'];
if (!$username) {
echo "You Must enter a username<br>";
$problem = "error";
}
if (!$postpassword) {
echo "You Must enter a password<br>";
$problem = "error";
}
if ($problem=="error") {
echo "<br><b>Your login was not sucessful</b><br><P>Click <a href=\"login.php\">here</a> to try again<br>";
} else {
$result = mysql_query("SELECT * from registration WHERE username ='$username'") or die(mysql_error());
$row = mysql_fetch_array( $result ) or die(mysql_error());
$numrows = mysql_num_rows($result);
$dbusername = $row['username'];
$dbpassword = $row['password']; 
$mobile = $row['msid']; 
$email = $row['email']; 
if ($numrows== NULL) {
echo "You username was not found<br><p>Not registered yet? Click <a href=\"register.php\">here</a> to register.. <b>its FREE!!</b><p><br>";
}
if ($username=$dbusername) {
echo "username match";
} 
if ($dbpassword==$postpassword) {
$_SESSION['username'] = $username;
$_SESSION['password'] = $postpassword;
$_SESSION['mobile'] = $mobile;
$_SESSION['email'] = $email;
$sidusername = $_SESSION['username'];
echo "<b>Welcome back $sidusername!</b>";
echo "<P><a href=\"download.php\">CLICK HERE TO SIMULATE A DOWNLOAD</a>";
} 
else {
echo "Your login was not sucessful<br><P>Click <a href=\"login.php\">here</a> to try again<br>";
}
}
?>

 

 

Can anyone see a reason why this code will not work?? It works if username or password is blank - but if it contains data it prints an empty screen.. I had it working before so I presume there is a little bug but I cant spot in.. Can anyone else??? ???

Link to comment
https://forums.phpfreaks.com/topic/74435-solved-php-login-script-not-working/
Share on other sites

OK, I changed it to

 

if ($username==$dbusername) {

echo "username match";

}

 

It still displayed a blank page - I added

 

<?php

error_reporting(E_ALL);

ini_set('display_errors', '1');

?>

 

and got the below error: -

 

 

Notice: Undefined variable: problem in processlogin.php on line 18

 

Line 18 been: -

 

if ($problem=="error") {

 

I tried to add this code (before line 18)

$problem = "none";

 

but then it just displays a blank page again..

 

ANY IDEAS????

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.