Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems w/ browsers and PHP

0 views
Skip to first unread message

xen...@sbcglobal.net

unread,
Dec 19, 2002, 11:45:46 AM12/19/02
to
Hi all,

I have noticed that a php based app I'm writing doesn't seem to work
correctly in Netscape and Opera, but seem to work fine in Links (under
linux) and Internet Explorer. I have included the source code below, and was
wondering if anyone could give some suggestions as to why those two browsers
won't finish running the page.

All the browsers I have tested it on, will display the login screen
correctly. Except NS and Opera will just refresh the same login page.

<?

/*
Default.php started to be written on 2002-07-30.
This will verify the person's id and password. If provided info is correct,
it will
let them click on the main menu page.
*/

//Set up a link to talk to mysql server.
$link= mysql_connect("localhost","username","password") or die ("Could not
connect to the server!");
//Tell php which database we wish to talk to.
mysql_select_db ("internal");

// Include functions that have already been written once.
include ('include/multi.php');

// Tell PHP server, we are going to need global variables.
session_cache_limiter('private');
// I added the session_cache_limiter to see if that would work, it had no
effect
session_start();

if (!empty ($_SESSION['username']))
{
do_html_header('Log In','','1');
}

// Have they already attempted to login?
if (!empty ($_POST['login']))
{
//Set $id variable from POST data
$id = $_POST['id'];

//Set $pass (password) variable from POST data
$pass = $_POST['pass'];

//Send query to MySQL server to see if id and password are valid
$result = mysql_query("select username from login where id = $id and
password = '$pass'");

//If there's an error in the sql statement, print the error, and then stop
running scripts.
if (!$result) {echo mysql_error(); exit;}

//If there are no returns, we obviously have a bad user id or password
if (mysql_num_rows($result)==0)
{
do_html_header('Log In');
echo "<center><font color='red'>Invalid User ID or
Password</font><br></center>";
?>
At this point remember that certain things will not work. And functions may
be look different from one click to the next, as it is being actively worked
on while your looking at it.<br>
If you have any suggestions as to what could be improved, please let me
know. Its easier to change things now, than to change them later.<br>

<table bgcolor="#c0c0c0" align="center">
<form action="default.php" method="post">
<tr><td>User ID:</td><td><input type="text" name="id" size=4 maxlength=4
/></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" size=10
maxlength=10></td></tr>
<tr><td align="center" colspan="2"><button name='login'
type='submit'>Login!</button></tr></td>
</form></table>
</body>
</html>
<?
exit;
}

//If there's a return, we have a valid user id and password
if (mysql_num_rows($result)==1)
{
$username =mysql_fetch_row($result);
session_register("username");
session_register("id");
//sleep (5);
do_html_header('Log In','','1');
echo "Log in Successfull. <br><a href='main.php'>Click here to go to main
menu</a><br>";
echo "</body></html>";

exit;
}

}
//They haven't tried to log in yet or they put in bad user name and/or
password
//Switch to HTML, display the form to input the information.
do_html_header('Log In');
?>
At this point remember that certain things will not work. And functions may
be look different from one click to the next, as it is being actively worked
on while your looking at it.<br>
If you have any suggestions as to what could be improved, please let me
know. Its easier to change things now, than to change them later.<br>

<table bgcolor="#c0c0c0" align="center">
<form action="default.php" method="post">
<tr><td>User ID:</td><td><input type="text" name="id" size=4 maxlength=4
/></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" size=10
maxlength=10></td></tr>
<tr><td align="center" colspan="2"><button name='login'
type='submit'>Login!</button></tr></td>
</form></table>
</body>
</html>

Below is from the Included file:

function do_html_header($title = '', $w2='2003', $jump='0',
$gowhere='main.php')
{
// print an HTML header

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$title?></title>
<link rel="stylesheet" type="text/css" href="include/styles.css">
<?
if ($jump > 0)
{ echo "<META HTTP-EQUIV='refresh' content='0;URL=$gowhere'>";}
?>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<body>
<table align="center">
<tr><td>
<div class="t1">XENiUM</div><div class="t2"> <?=$w2 ?></div></td>
<?
if (isset ($_SESSION['id']))
{
$id = $_SESSION['id'];
$result = mysql_query("select username from login where id = $id");
if (!$result){echo "Session ID: ".mysql_error(); exit;}
$row = mysql_fetch_row($result);
?>
<tr><td align="center">You are logged in as: <? echo $row[0]; ?></td></tr>
<?
}
else echo "<td>&nbsp;</td></tr>";
?>
</table>
<?
}

Any help will be greatly appreciated,
Chris
--
Chris Moody
webm...@xeniumcorp.net


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.426 / Virus Database: 239 - Release Date: 12/2/02


stephan beal

unread,
Dec 19, 2002, 11:57:11 AM12/19/02
to
xen...@sbcglobal.net wrote:
> I have noticed that a php based app I'm writing doesn't seem to work
> correctly in Netscape and Opera, but seem to work fine in Links (under
> linux) and Internet Explorer.

This is 100% the fault of the generated HTML/cookies/etc, not PHP. PHP
executes 100% server-side, completely oblivious to what browser you are
using. It will give us the same output regardless of whether we use MSIE,
wget or lynx. (Granted, PHP apps *can* change their output based on the
user agent, but this is a function of the application, not the language,
and is therefor not a fault in PHP.)

--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.

xen...@sbcglobal.net

unread,
Dec 19, 2002, 12:03:44 PM12/19/02
to

"stephan beal" <ste...@wanderinghorse.net> wrote in message
news:atstp5$q6r$1...@ork.noris.net...

> xen...@sbcglobal.net wrote:
> > I have noticed that a php based app I'm writing doesn't seem to work
> > correctly in Netscape and Opera, but seem to work fine in Links (under
> > linux) and Internet Explorer.
>
> This is 100% the fault of the generated HTML/cookies/etc, not PHP. PHP
> executes 100% server-side, completely oblivious to what browser you are
> using. It will give us the same output regardless of whether we use MSIE,
> wget or lynx. (Granted, PHP apps *can* change their output based on the
> user agent, but this is a function of the application, not the language,
> and is therefor not a fault in PHP.)
>
Hi Stephan,

Thanks for the quick reply, can you see anything in my code that would
prevent Netscape or Opera from handeling my page correctly?

Chris

André Næss

unread,
Dec 19, 2002, 12:19:16 PM12/19/02
to
xen...@sbcglobal.net wrote:

> Thanks for the quick reply, can you see anything in my code that would
> prevent Netscape or Opera from handeling my page correctly?

The code isn't relevant. What is relevant is the HTML *generated* by the
code, so what you probably should do is ask for help in some HTML group.

But first, try running the generated HTML through a validator, e.g.
http://validator.w3.org to see if you've made any obvious mistakes, like
forgetting to close some tags.

André Næss

0 new messages