-
Hi Guys,
How can i get the URL address in my membership.php to display that URL. At the moment, when the user logs in the validate.php script kicks in....part of the script is below. If the user is a valid user they will be taken to membership.php. This all works fine except for the URL address in the membership.php page, it currently reads validate.php.
How can i change this?
Cheers,
micmac
<?
if (session_is_registered(\"valid_user\"))
{
// logged in successfully to membership area
require(\"membership.php\");
}
else
{
if (isset($userid))
{
// if they\'ve tried and failed to log in
require(\"warning.php\");
}
else
{
// they have not tried to log in yet or have logged out
require(\"warning.php\");
}
}
?>
-
Hi,
I dont think I understand your question
Musicman
-
Hi Musicman,
I didn't think i explained it that well...i'll give it another try.
This is my validate.php page:
<?
session_start();
if ($userid && $password)
{
// if the user has just tried to log in
$db_conn = mysql_connect('localhost', '', '');
mysql_select_db("psp", $db_conn);
$query = "SELECT * FROM members WHERE login_name='$userid' AND password='$password'";
$result = mysql_query($query, $db_conn);
if (mysql_num_rows($result) >0 )
{
// if they are in the database register the user id
$valid_user = $userid;
session_register("valid_user");
}
}
?>
<html>
<body>
<?
if (session_is_registered("valid_user"))
{
// logged in successfully to membership area
include_once("membership.php");
}
else
{
if (isset($userid))
{
// if they've tried and failed to log in
include_once("warning.php");
}
else
{
// they have not tried to log in yet or have logged out
include_once("warning.php");
}
}
?>
I've changed the code a little since last post, i'm not even sure if this is the best way to do it, that is using the include_once()....or should i be using the include() or the require()?
Anyhow, the problem i have is that when the user places their username and password then presses submit the validate.php script is executed. Everything works fine, if the username and password are valid then it goes to the membership.php page. The page comes up but instead of the http://localhost/membership.php URL in the browsers address it displays http://localhost/validate.php
How can i get it to display http://localhost/membership.php instead?
-
Hi,
of course it does - since nothing happens to your browser.
If you want the browser to change, do a
header('Location: membership.php')
rather than include it - this way the browser loads the membership page.
Of course you should add code to membership.php so that someone who tries to open the page directly is kicked back to login
Musicman
-
I get this warning:
Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\validate.php:23) in c:\phpdev\www\validate.php on line 28
line 23 is the opening php tag. ie: <?
line 28 is the header () line.
if (session_is_registered("valid_user"))
{
// logged in successfully to membership area
header ("Location: http://localhost/membership.php ");
}
Any ideas?
[Edited by micmac on 04-01-2002 at 04:58 AM]
-
Thanks Musicman.....got it working
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|