0

I'm having some problems on gettin the Login page to redirect the users back to the login page with error message if they input the incorrect login details...

But instead of the redirect i receive an blank white screen (Nothing in View Source and Nothing on page).. How do i fix these issue.

Codes Below:

<?php
session_start();
require("db.php");
    
 
  if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE) 
  {
   header("Location: " . $config_basedir);
  }
  if(isset($_POST['submit']))
  {
    $loginsql = "SELECT * FROM database_Name.users WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "'";
    $loginres = mysql_query($loginsql) or die (mysql_error());
    $numrows = mysql_num_rows($loginres)or die (mysql_error());
    
			if($numrows == 1)
			{
			  $loginrow = mysql_fetch_assoc($loginres);
			  
			  session_register("SESS_LOGGEDIN");
			  session_register("SESS_USERNAME");
			  session_register("SESS_USERID");
			  
			  $_SESSION['SESS_LOGGEDIN'] = 1;
			  $_SESSION['SESS_USERNAME'] = $loginrow['username'];
			  $_SESSION['SESS_USERID'] = $loginrow['id'];
			  header("Location:http://www.webaddress.com/index.php"); 
			 }
		  else
			{
			  header("Location:http://www.webaddress.com/login.php?error=1");
			}
	}
?>

Thanks in advance =)

3
Contributors
8
Replies
11
Views
6 Years
Discussion Span
Last Post by karthik_ppts
0

I'm having some problems on gettin the Login page to redirect the users back to the login page with error message if they input the incorrect login details...

But instead of the redirect i receive an blank white screen (Nothing in View Source and Nothing on page).. How do i fix these issue.

Codes Below:

<?php
session_start();
require("db.php");
    
 
  if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE) 
  {
   header("Location: " . $config_basedir);
  }
  if(isset($_POST['submit']))
  {
    $loginsql = "SELECT * FROM database_Name.users WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "'";
    $loginres = mysql_query($loginsql) or die (mysql_error());
    $numrows = mysql_num_rows($loginres)or die (mysql_error());
    
			if($numrows == 1)
			{
			  $loginrow = mysql_fetch_assoc($loginres);
			  
			  session_register("SESS_LOGGEDIN");
			  session_register("SESS_USERNAME");
			  session_register("SESS_USERID");
			  
			  $_SESSION['SESS_LOGGEDIN'] = 1;
			  $_SESSION['SESS_USERNAME'] = $loginrow['username'];
			  $_SESSION['SESS_USERID'] = $loginrow['id'];
			  header("Location:http://www.webaddress.com/index.php"); 
			 }
		  else
			{
			  header("Location:http://www.webaddress.com/login.php?error=1");
			}
	}
?>

Thanks in advance =)

Did you try check on the 'if' nesting?

0

try check if the 'ifs' are properly nested.
when you put if and else, it should know what 'if' to 'else'!

0

Yay! Thanks soooo much! It worked... lol

I cant believe it took me that long just to figure out that the die was killin the script b.c it was turing negative... OMG

Thanks!

0

Yay! Thanks soooo much! It worked... lol

I cant believe it took me that long just to figure out that the die was killin the script b.c it was turing negative... OMG

Thanks!

Mark as solved if your problem is solved.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.