View previous topic :: View next topic |
Author |
Message |
Neil Guest
|
Posted: Sun Jan 05, 2003 6:42 pm Post subject: PHP script - works with apache, not with abyss |
|
|
I'm having problems with a login script I wrote in php. The action of the form is pointed to <?=$php_self?>. If I run it via apache, using the latest php version, when you press the login button it works correctly, and if you view the source the path is displayed under action, rather than the php.
If I use abyss, pressing login does nothing, but if you view the source the action path is correctly inserted, so php is running. It can't be a problem with php as it works fine with apache, so I think its gotta be abyss.
If you need any of the code, let me know,
plz help,
neil |
|
Back to top |
|
|
!Keys -
Joined: 23 Nov 2002 Posts: 156 Location: Holland, Enschede
|
Posted: Sun Jan 05, 2003 7:49 pm Post subject: Re: PHP script - works with apache, not with abyss |
|
|
<?=$php_self?>
is not correct php code.. and are you very sure it´s the exact same script and exactly the same php version? te newest php version requires other coding _________________ !Keys || MwM^computerware |
|
Back to top |
|
|
Guest
|
Posted: Sun Jan 05, 2003 8:02 pm Post subject: |
|
|
yes, and I tried using the previous version of php too. Neither work with abyss, whilst both work with apache. That is the correct code, however I have also tried
<form method="post" action="<? echo($_SERVER['PHP_SELF']) ?>">
if you look at the source code of the page in a browser, it correctly points to the file itself.
Perhaps this is a bug?
Here is the script I am using:
Home.php (just a content page).
Code: |
<?php //home.php
include("restrict.php"); ?>
<LINK REL=stylesheet HREF="style.css" TYPE="text/css">
<html>
<head>
<title> Members-Only Page </title>
</head>
<body>
<p align="center"><img src="images/logo1.gif" width="279" height="77"></p>
<p><font size="2" face="tahoma, verdana, arial">Welcome, <? echo($fullname) ?>.
You have successfully logged on. Account management, team creation and management,
and password editing facilities are now available. The script core is now under
development, and should be ready in time for the new f1 season, or hopefully
before to allow signups!<br>
</font></p>
<p align="center"><? include('carnav.php') ?></p>
</body>
</html>
|
Restrict.php - I include this into any document which I want to be password protected, ie it check for the login session.
Code: |
<?php // restrict.php
include("common.php");
include("db.php");
session_start();
if(!isset($uid)) {
?>
<html>
<head>
<title> Please Log In for Access </title>
</head>
<body>
<h2> <font color="#006600" face="tahoma, verdana, arial">Please Login</font></h2>
<p><font size="2" face="tahoma, verdana, arial">You must log in to access this area of
the site. If you are not a registered user, <a href="signup.php">click here</a>
to get yourself an account, and your own team!</font></p>
<p>
<form method="post" action="<? echo($_SERVER['PHP_SELF']) ?>">
<font size="2" face="tahoma, verdana, arial"> </font>
<table width="285" border="0" cellspacing="1">
<tr>
<td width="91"><font size="2" face="tahoma, verdana, arial">User ID:</font></td>
<td width="187"><font size="2" face="tahoma, verdana, arial">
<input type="text" name="uid" size="8">
</font></td>
</tr>
<tr>
<td><font size="2" face="tahoma, verdana, arial">Password: </font></td>
<td><font size="2" face="tahoma, verdana, arial">
<input type="password" name="pwd" size="8">
</font></td>
</tr>
<tr>
<td><font size="2" face="tahoma, verdana, arial">
<input name="submit" type="submit" value="Log in">
</font></td>
<td> </td>
</tr>
</table>
</form>
<font size="2" face="tahoma, verdana, arial"></p> <img src="images/blur1.gif" width="308" height="129"></font>
</body>
</html>
<?php
exit;
}
session_register("uid");
session_register("pwd");
dbConnect("f1");
$sql = "SELECT * FROM users WHERE
username = '$uid' AND password = PASSWORD('$pwd')";
$result = mysql_query($sql);
if (!$result) {
error("A database error occurred while checking your ".
"login details.\\nIf this error persists, please ".
"contact neil.ord@ntlworld.com");
}
if (mysql_num_rows($result) == 0) {
session_unregister("uid");
session_unregister("pwd");
?>
<html>
<head>
<title> Access Denied </title>
</head>
<body>
<h2> <font color="#990000" face="tahoma, verdana, arial">Access Denied </font></h2>
<p><font size="1" face="tahoma, verdana, arial"><font size="2">Your user ID or
password is incorrect, or you are not a registered user on this site. To try
logging in again, click <a href="<?=$PHP_SELF?>">here</a>. To register for instant
access, click <a href="signup.php">here</a>.</font></font></p>
</body>
</html>
<?php
exit;
}
$fullname = mysql_result($result,0,"name");
?>
|
I dont think it is a problem with my php setup as phpmyadmin works great..I am using php 4.3, the latest mysql, and Abyss X1 |
|
Back to top |
|
|
!Keys -
Joined: 23 Nov 2002 Posts: 156 Location: Holland, Enschede
|
Posted: Sun Jan 05, 2003 8:29 pm Post subject: |
|
|
I have no idea, i havn´t programmed Abyss. Think it´s soem kind of bug in the abyss-php connection thing or something ? _________________ !Keys || MwM^computerware |
|
Back to top |
|
|
Bluedog -
Joined: 05 Jan 2003 Posts: 179
|
Posted: Sun Jan 05, 2003 8:35 pm Post subject: |
|
|
(this is neil/guest, got me an account)
yeh I guess it must be - nothing happens at all when you click login, no php/mysql/abyss error, or none of my custom errors... |
|
Back to top |
|
|
Bluedog -
Joined: 05 Jan 2003 Posts: 179
|
Posted: Mon Jan 06, 2003 12:10 am Post subject: |
|
|
in fact, it might just be a bug with all form POSTing....I've tried another one, and the submit button does nothing on that other, the action was zzz.php and the filename was zzz.php - i did that instead of php_self... |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Jan 06, 2003 12:46 am Post subject: Re: PHP script - works with apache, not with abyss |
|
|
The script runs OK on Abyss Web Server too. We tested it and no problems with the Login button. It works.
So why you have problems? Simply because you use the old PHP variable naming convention (and this is a PHP problem.) So please consider reading http://www.aprelium.com/forum/viewtopic.php?t=274 to know how to transform variable in your script or how to make PHP backward compatible with the old way of doing things. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Bluedog -
Joined: 05 Jan 2003 Posts: 179
|
Posted: Mon Jan 06, 2003 12:16 pm Post subject: |
|
|
Hi
Thanks for your response aprelium :)
I've done what you said, but I'm still having problems...it does not say access denied or let you into the home.php still...
I have done as you said with the variables, but it doesnt work...what exactly did you do when testing it?
Neil[/code] |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Jan 06, 2003 11:47 pm Post subject: |
|
|
Bluedog wrote: | Hi
Thanks for your response aprelium :)
I've done what you said, but I'm still having problems...it does not say access denied or let you into the home.php still...
I have done as you said with the variables, but it doesnt work...what exactly did you do when testing it?
Neil[/code] |
We cut the part in the script that deals with the MySQL database. And everything worked fine. So you may have problems with that part (this is a programming problem in your script in that case.) So please review that part and try to debug the script. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Bluedog -
Joined: 05 Jan 2003 Posts: 179
|
Posted: Tue Jan 07, 2003 12:37 pm Post subject: |
|
|
Hi
I have also tried removing this, but it still does not work. On pressing login, you should either get an access denied page, or access to home.php. If I use either the new OR old version of php with abyss, it does not work, so it can't be due to a new version. BOTH versions of php allow this script to work correctly with apache, which is why I think it has got to be an abyss, or an abyss installation/config problem. If I am using the same php files, the same script, and it works with apache but not with abyss, surely it must be something to do with abyss?
Thanks for your assistance,
Neil |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Wed Jan 08, 2003 12:01 am Post subject: |
|
|
Apache doesn't do any PHP processing for you and no web server does that. It is php.exe that does that. So if you are testing the script with the same php installation, you should get the same results. But if you tried that script on another computer with another PHP installed, things may vary and Abyss Web Server has nothing to do with that.
And as we said above, we tested the script and ot works without any problem so why isn't working on your computer???? That's the question.
Here is the rstrict.php that we tested (some parts were commented as we said, those parts are dealing with the database access):
Code: |
<?php // restrict.php
/*include("common.php");
include("db.php"); */
session_start();
if(!isset($uid)) {
?>
<html>
<head>
<title> Please Log In for Access </title>
</head>
<body>
<h2> <font color="#006600" face="tahoma, verdana, arial">Please Login</font></h2>
<p><font size="2" face="tahoma, verdana, arial">You must log in to access this area of
the site. If you are not a registered user, <a href="signup.php">click here</a>
to get yourself an account, and your own team!</font></p>
<p>
<form method="post" action="<? echo($_SERVER['PHP_SELF']) ?>">
<font size="2" face="tahoma, verdana, arial"> </font>
<table width="285" border="0" cellspacing="1">
<tr>
<td width="91"><font size="2" face="tahoma, verdana, arial">User ID:</font></td>
<td width="187"><font size="2" face="tahoma, verdana, arial">
<input type="text" name="uid" size="8">
</font></td>
</tr>
<tr>
<td><font size="2" face="tahoma, verdana, arial">Password: </font></td>
<td><font size="2" face="tahoma, verdana, arial">
<input type="password" name="pwd" size="8">
</font></td>
</tr>
<tr>
<td><font size="2" face="tahoma, verdana, arial">
<input name="submit" type="submit" value="Log in">
</font></td>
<td> </td>
</tr>
</table>
</form>
<font size="2" face="tahoma, verdana, arial"></p> <img src="images/blur1.gif" width="308" height="129"></font>
</body>
</html>
<?php
exit;
}
session_register("uid");
session_register("pwd");
/*dbConnect("f1");
$sql = "SELECT * FROM users WHERE
username = '$uid' AND password = PASSWORD('$pwd')";
$result = mysql_query($sql);
if (!$result) {
error("A database error occurred while checking your ".
"login details.\\nIf this error persists, please ".
"contact neil.ord@ntlworld.com <mailto:neil.ord@ntlworld.com>");
}
if (mysql_num_rows($result) == 0) */{
session_unregister("uid");
session_unregister("pwd");
?>
<html>
<head>
<title> Access Denied </title>
</head>
<body>
<h2> <font color="#990000" face="tahoma, verdana, arial">Access Denied </font></h2>
<p><font size="1" face="tahoma, verdana, arial"><font size="2">Your user ID or
password is incorrect, or you are not a registered user on this site. To try
logging in again, click <a href="<?=$PHP_SELF?>">here</a>. To register for instant
access, click <a href="signup.php">here</a>.</font></font></p>
</body>
</html>
<?php
exit;
}
$fullname = mysql_result($result,0,"name");
?>
|
_________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Bluedog -
Joined: 05 Jan 2003 Posts: 179
|
Posted: Wed Jan 08, 2003 5:01 pm Post subject: |
|
|
I cant understand it.
I am using the same script, the same php installation, and the same pc, yet with abyss it does not work...perhaps it is my configuration, as the altered script you gave me also does not work - it should go to the access denied page but it does not....
should i post my abyss.conf here? |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Wed Jan 08, 2003 11:57 pm Post subject: |
|
|
Bluedog wrote: | I cant understand it.
I am using the same script, the same php installation, and the same pc, yet with abyss it does not work...perhaps it is my configuration, as the altered script you gave me also does not work - it should go to the access denied page but it does not....
should i post my abyss.conf here? |
abyss.conf has nothing to do with PHP. It is your PHP.ini that holds the PHP configuration. If you want, please send it to support@aprelium.com si that we can verify it. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Bluedog -
Joined: 05 Jan 2003 Posts: 179
|
Posted: Fri Jan 10, 2003 4:58 pm Post subject: |
|
|
thanks! I emailed support, and it turned out I missed a setting in my php.ini file.
Thanks for all of your assistance aprelium, and the support team,
Neil |
|
Back to top |
|
|
Guest
|
Posted: Wed Jan 15, 2003 11:21 pm Post subject: |
|
|
heh, this is funny, i got the same problem, however, if I run it locally, under http://127.0.0.1:8080/bla.php any form that I post works fine.
If I try the same script from my external IP address (even on the same computer) (http://62.195.45.xx:8080/bla.php) the form vars don't get posted.
no $_POST, $_GET, $_REQUEST vars are set, and no sign of anything i entered in the form is visible when i debug the script with phpinfo(); |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Jan 18, 2003 12:53 am Post subject: |
|
|
Anonymous wrote: | heh, this is funny, i got the same problem, however, if I run it locally, under http://127.0.0.1:8080/bla.php any form that I post works fine.
If I try the same script from my external IP address (even on the same computer) (http://62.195.45.xx:8080/bla.php) the form vars don't get posted.
no $_POST, $_GET, $_REQUEST vars are set, and no sign of anything i entered in the form is visible when i debug the script with phpinfo(); |
Very strange... What do you mean by 'no sign of anything'? What does phpinfo() output? _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
rIkLuNd -
Joined: 15 Jan 2003 Posts: 25 Location: Örebro, Sweden
|
Posted: Sat Jan 18, 2003 3:15 am Post subject: |
|
|
I also use Abyss Web Server, and I've never had any of these problems... $_SERVER['PHP_SELF'] is working perfectly fine for me... I have the newest version of PHP installed... Might that be the explanation? |
|
Back to top |
|
|
Guest
|
Posted: Sat Jan 18, 2003 2:05 pm Post subject: |
|
|
aprelium wrote: |
Very strange... What do you mean by 'no sign of anything'? What does phpinfo() output? |
well, my form looks like this:
Code: |
<form method="post" action="account.php">
<tr> <td align="right" nowrap><font face="arial" size="-1">Username</font></td>
<td><input name="username" size="25" value=""></td>
</tr>
<tr> <td align="right" nowrap><font face="arial" size="-1">Password</font></td>
<td><input name="passwd" type="password" size="25" maxlength="32"></td></tr>
<tr> <td colspan="2" nowrap align="center"><font face="arial" size="-1">
<td><input name="submit" type="submit" value="Sign In"></td>
</tr>
<input type="hidden" name="action" value="login">
<input type="hidden" name="success" value="{SUCCESS}">
<input type="hidden" name="submit" value="submit">
</form>
|
my php script looks like this:
Code: |
<?
// do some initializing
$action = $_REQUEST['action'];
$submit = $_REQUEST['submit'];
switch ($action) {
case 'login':
if (isset($submit)) {
if ($ticket = $acc->process_login()) {
if (isset($_REQUEST["success"])) {
$success=urldecode($_REQUEST["success"]);
} else {
$success=$HTTP_REFERER;
}
Header("Location: $success&ticket=$ticket");
break;
} else { echo "bad login"; }
}
$acc->show_login_form("out"); break;
default: echo $action; break;
}
// do some template stuff here, such as parsing "out"
?>
|
If I use method="POST" in my form, my phpscript goes to case default, with this output:
Code: | Error 200
OK
--------------------------------------------------------------------------------
Abyss Web Server X1
© Aprelium Technologies - 2001-2002
|
(obviously, because $action seems not to be set., thus creating an empty document)
vital phpinfo() output:
Code: |
REQUEST_METHOD GET
SERVER_PORT 8080
REMOTE_ADDR 62.195.45.xx
SCRIPT_NAME /account.php
ENV["REQUEST_METHOD"] GET
|
seems like even though I POST the form, php _thinks_ I use the GET method.
I just checked my script, and if I use method="GET" in my form, everything seems to work fine. (form gets processed, i get redirected to the right URI etc etc)
Could this be a PHP bug? The weird thing is that when I test the script locally, everything works fine, even with the method="POST". |
|
Back to top |
|
|
Guest
|
Posted: Sat Jan 18, 2003 2:09 pm Post subject: |
|
|
[quote="Anonymous]
[..]
[/quote]
gheh, can't edit my post, but in reply to rIkLuNd: here's the software stats:
Windows XP professional
php-4.3.0
mysql4.0.7-gamma
Abyss web server X1
ZoneAlarm Pro 3.5.169.002 (already tried disabling it; no change)
Windows internal firewall disabled
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|