Ask a Question related to PHP Programming, Design and Development.
-
Topspin #1
Redirection Problem
I'm running PHP on Windows, but that's just the local test... in production
it will be on Apache.
I am not using PHP as a CGI. I want to perform redirection of the user's
browser if the user isn't a valid user. I don't want to use the refresh
meta tag or javascript to do this. I want to do this with some sort of
server command.
Does anyone know how to make this work? Here's my code...
<?php
session_start();
$goal = "";
if (array_key_exists('goal', $_GET)) { $goal = $_GET['goal']; }
if (isset($HTTP_POST_VARS['userid']) && isset($HTTP_POST_VARS['password']))
{
$userid = $HTTP_POST_VARS['userid'];
$password = $HTTP_POST_VARS['password'];
$db_conn = mysql_connect('localhost', 'webauth', 'webauth');
mysql_select_db('auth', $db_conn);
$query = "select * from auth where name='$userid' and
pass=password('$password')";
$result = mysql_query($query, $db_conn);
if (mysql_num_rows($result) > 0) {
$HTTP_SESSION_VARS['valid_user'] = $userid;
}
}
?>
<?
if (isset($HTTP_SESSION_VARS['valid_user'])) {
// redirection code goes here. Re-direct to value current to the value of
$goal which is a html file in the current directory http directory
} else {
if (isset($userid)) {
echo 'Could not log you in';
} else {
echo 'You are not logged in <br/>';
}
echo '<html><body><form method="post" action="authmain.php">';
echo '<table>';
echo '<tr><td>Userid:</td><td><input type="text" name="userid"></td></tr>';
echo '<tr><td>Password:</td><td><input type="password"
name="password"></td></tr>';
echo '<tr><td colspan="2" align="center"><input type="submit" value="Log
In"></td></tr>';
echo '</table></form></body></html>';
}
?>
Topspin Guest
-
Passport Redirection Problem.
Hi. all!!!!!!!! With Passport Authentication AFTER SESSION TIME OUT How can i redirect the user to the Passport login page. And after... -
redirection
Thank you for your hel my question is: How can I redirect a visitor to a HTML site if he does not have flash plugin instaled on his computer? on my... -
Redirection Help Please
I try to use PHP to redirect to other page and failed. Please give me a help. Thanks. The script is: if($rows_num>0) { session_start();... -
header() redirection/session variable problem
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication... -
Problem with redirection in a Form...
Hi, Envronment: IIS 5 on W2k sp3 Problem: I'm using a Form and when Submitted, will display a confirmation page. The confirmation page is... -
Frank #2
Re: Redirection Problem
Topspin wrote:
Hi Topspin,> I'm running PHP on Windows, but that's just the local test... in
> production it will be on Apache.
>
> I am not using PHP as a CGI. I want to perform redirection of the user's
> browser if the user isn't a valid user. I don't want to use the refresh
> meta tag or javascript to do this. I want to do this with some sort of
> server command.
>
> Does anyone know how to make this work? Here's my code...
just set the http-location-header like so:
header("location: $newurl");
The users browser should then load this new URL.
Make sure -as usual with the call to header- that your script
did not write anything out prior to the function call.
A simple blank somewhere in an included file is sufficient to let your
call fail.
Cheers
Frank
Frank Guest
-
Shawn Wilson #3
Re: Redirection Problem
Topspin wrote:
Upon finding out that they're not valid:> I am not using PHP as a CGI. I want to perform redirection of the user's
> browser if the user isn't a valid user. I don't want to use the refresh
> meta tag or javascript to do this. I want to do this with some sort of
> server command.
header("Location: http://www.getouttahere.com");
Make sure you write this BEFORE your script produces any output. Even a single
space will cause you grief. Also, be sure to use an absolute URL. Relative
URLs will work in some newer browsers, but cause trouble in others.
Shawn
--
Shawn Wilson
[email]shawn@glassgiant.com[/email]
[url]http://www.glassgiant.com[/url]
Shawn Wilson Guest
-
kirsto #4
Redirection problem
Hi there, I am new to contribute. I have set up a new index page for my website
however it is still redirecting to an old page that was filling a gap while the
new page was being built. Unfortunately the page it redircts to was not made by
us and is under a domain owned by someone else. What setting do I need to
change in order to stop the automatic redirection?
Cheers.
kirsto Guest
-
sharonbaker #5
Re: Redirection problem
Hello everyone....
I am new to here. I think this is right place for learning about the PHP. Thanks
Junior Member
- Join Date
- Feb 2011
- Posts
- 1



Reply With Quote

