Jump to content

Recommended Posts

Okay, im no master with php here... but i have a login script that i use and works fine as far as I know.. BUT this is my issue..

 

on this machine(host) i use firefox, logs in fine. try IE, doesn't work.

tried ie on my laptop, worked fine.

other users some can, some can't. What could this be related to? not sure what code I would post for it, since it working only for select few?

 

Hope that is clear, any help would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/158317-login-issues/
Share on other sites

Is your code attempting to use the ip address, user agent information,  http_referer, or javascript? Have you validated the HTML of your form so that you can eliminate invalid HTML as the cause (some browsers and some versions of some browsers ignore HTML errors that would allow a form to work, which others don't.)

 

Posting your form and the form processing code (all the relevant code that someone would need in order to duplicate the problem) would be the quickest way for someone to determine if the problem is within your code or is due to browser problems.

 

And as Porl123 just asked, what exactly are the symptoms when it does not work?

Link to comment
https://forums.phpfreaks.com/topic/158317-login-issues/#findComment-835014
Share on other sites

Here is code for form.

 

$error = $_GET['op'];
...
<form method="post" action="login.php" name="LogIn">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">

<?
	if ( $error == 'error')
	{
		echo "<tr><td colspan=\"2\" align=\"center\" valign=\"bottom\"><div class=\"postby\">ERROR: INCORRECT PASSWORD OR USERNAME</div></td></tr>\n";
	}
?>

<tr>
	<td align="center" valign="middle">
		<table border="1" width="150" height="10%" cellpadding="0" cellspacing="2">
			<tr>
				<td align="right"><div class="field">USERNAME:</div></td>
				<td>
					<input type="text" name="U_NAME" maxlength="15" size="7" style="background-color: #666666; color: #FFFFFF; border: none;" />
				</td>
			</tr>
			<tr>
				<td align="right"><div class="field">PASSWORD:</div></td>
				<td>
					<input type="password" name="U_PASS" maxlength="20" size="7" style="background-color: #666666; color: #FFFFFF; border: none;" />
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" name="DoLogIn" value="Log In" style="background-color: #999999; color: #FFFFFF; border: 1px solid #FFFFFF; align=center" />
				</td>
			</tr>
		</table>
	</td>
</table>
</form>

 

and the php

 

<?php
session_start();
/**
* @author BSkopnik
* @copyright 2009
*/

require "global_data.php";

if ( $_POST["DoLogIn"] )
{
$up_link = mysql_connect( $DB_HOST, $DB_UNAME, $DB_UPASS ) or die( mysql_error() );
mysql_selectdb( $DB_NAME ) or die( mysql_error() );

$name = stripslashes($_POST["U_NAME"]);
$pass = stripslashes($_POST["U_PASS"]);

$name = strtolower( $name );
$pass = strtolower( $pass );

$query = "SELECT * FROM users WHERE username='$name' and password='$pass'";
$result = mysql_query( $query );

$count = mysql_num_rows( $result ) or die( mysql_error() );

if ( $count == 1 )
{
	$logged = TRUE;
	$_SESSION["LoggedIn"] = $logged;
	$_SESSION["Name"] = $name;
	header("location:cp.php");
}else
{
	header("location:index2.php?op=error");	
}

}else
{
echo "ERROR: Cannot access page. Please check your link and try again.";
}
?>

 

For alot of people ( in ie ) it justs kicks back saying wrong user/pass. even with right name password.

 

EDIT: Had a typo for some code..fixed the typo.

Link to comment
https://forums.phpfreaks.com/topic/158317-login-issues/#findComment-835066
Share on other sites

What have you done to troubleshoot what it is doing? Have you done a print_r($_POST) to even see what is being sent from the form?

 

It is likely that because you don't have any exit; statements after your header() redirects that when your code continues running on the page that it causes the incorrect operation and that the key ingredients are both which browser but also the speed of the Internet connection.

 

At a minimum add an exit; statement after every header() redirect.

 

And if that does not solve the problem, please post all of your page with the form and identify which file is which? Is the first piece of posted code really index2.php?

Link to comment
https://forums.phpfreaks.com/topic/158317-login-issues/#findComment-835090
Share on other sites

Alright, i tried listing all the variables, will be posting my code now.. but, I had used isset( $_POST["DoLogIn"]) which seemed to fix some peoples issues to log in, but some still can't, and end up blank page. I'm stuck

 

index2.php

<?php

if ( isset($_SESSION["LoggedIn"]) )
{
session_destroy();
}
/**
* @author BSkopnik
* @copyright 2009
*/

$error = $_GET['op'];
$today = date( "D F d");
?>

<html>
<head>
<title>TWC :: Login (<? echo $today; ?>)</title>
<link rel='stylesheet' type='text/css' href='css/sheet.css' title='style' />
</head>
<body bgcolor="White">
<form method="post" action="login.php" name="LogIn">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">

<?
	if ( $error == 'error')
	{
		echo "<tr><td colspan=\"2\" align=\"center\" valign=\"bottom\"><div class=\"postby\">ERROR: INCORRECT PASSWORD OR USERNAME</div></td></tr>\n";
	}
?>

<tr>
	<td align="center" valign="middle">
		<table border="1" width="150" height="10%" cellpadding="0" cellspacing="2">
			<tr>
				<td align="right"><div class="field">USERNAME:</div></td>
				<td>
					<input type="text" name="U_NAME" maxlength="15" size="7" style="background-color: #666666; color: #FFFFFF; border: none;" />
				</td>
			</tr>
			<tr>
				<td align="right"><div class="field">PASSWORD:</div></td>
				<td>
					<input type="password" name="U_PASS" maxlength="20" size="7" style="background-color: #666666; color: #FFFFFF; border: none;" />
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" name="DoLogIn" value="Log In" style="background-color: #999999; color: #FFFFFF; border: 1px solid #FFFFFF; align=center" />
				</td>
			</tr>
		</table>
	</td>
</table>
</form>
</body>
</html>	

 

login.php

<?php
session_start();
/**
* @author BSkopnik
* @copyright 2009
*/

require "global_data.php";

if ( isset($_POST["DoLogIn"]) )
{
$up_link = mysql_connect( $DB_HOST, $DB_UNAME, $DB_UPASS ) or die( mysql_error() );
mysql_selectdb( $DB_NAME ) or die( mysql_error() );

$name = stripslashes($_POST["U_NAME"]);
$pass = stripslashes($_POST["U_PASS"]);

$name = strtolower( $name );
$pass = strtolower( $pass );

/*$query = "SELECT * FROM users";
$result = mysql_query( $query ) or die( mysql_error() );

while ( $row = mysql_fetch_array($result))
{
	echo $row["username"] . "<br />";
	echo $row["password"] . "<br />";
}
*/
$query = "SELECT * FROM users WHERE username='$name' and password='$pass'";
$result = mysql_query( $query );

$count = mysql_num_rows( $result ) or die( mysql_error() );

if ( $count == 1 )
{
	$logged = TRUE;
	$_SESSION["LoggedIn"] = $logged;
	$_SESSION["Name"] = $name;
	header("location:cp.php");
	exit;
}else
{
	header("location:index2.php?op=error");
	exit;
}

}else
{
echo "ERROR: Cannot access page. Please check your link and try again.";
}
?>

 

cp.php

<?php
session_start();
/**
* @author BSkopnik
* @copyright 2009
*/
include ("global_data.php");

if ( !$_SESSION["LoggedIn"] )
{
header("location:index2.php?op=error");
exit;
}

$today = date( "D F d");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The War Council :: Home (<? echo $today; ?>)</title>
<link rel="stylesheet" type="text/css" href="css/sheet.css" title="style">	
</head>
<body bgcolor="White">
<center>
<table border="0" width="640">
	<!-- Build table, 2 columns -->
	<tr>
		<td align="center">
			<!-- Menu -->
			<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
			<table border="0" cellpadding="0" cellspacing="0">
				<?
					if ( ($_SESSION["LoggedIn"]) && ($_SESSION["Name"] == "admin") )
					{
						echo $umenu;
					}else
					{
						echo $menu;
					}
				?>
			</table>
		</td>
		<td align="center" valign="middle">
			<!-- Page Content -->
			<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
			<table border="1" bordercolor="#000000" cellpadding="0" cellspacing="0" width="200">
				<tr>
					<td>
						<div class="pagetitle">HOME</div>
						<div class="content">
							... This is where content was.. took out for sake of showing code ...
						</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</center>
</body>
</html>

 

the $menu, and $umenu are located in the global_data.php which just as my mysql info in it.

 

So like I said, I had played with showing the post vars, and session vars to make sure they were all setting correctly,and they were. Just can't seem to figure out why some peolpe are getting just a blank screen after clicking log in. Any help would be appreciated, thanks.

Link to comment
https://forums.phpfreaks.com/topic/158317-login-issues/#findComment-836525
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.