Jump to content

Archived

This topic is now archived and is closed to further replies.

BaconBeast321

Please tell me the function name I need LoL!

Recommended Posts

Hi there, I have a site with a login that goes to a page logging.php to process data, then I want it to go to membersarea.php afterwards..

My IF/ELSE statement is the following:

<?php if ( isset($username) ): ?> (if username has a value)


*********************************************************
--------------------------------------------------------------------------------------------
I need a function here that automatically takes the user to membersarea.php
----------------------------------------------------------------------------------------------
***********************************************************


<?php else
echo("Not logged in!");
?>




Any help would be awesome! I haven't been able to find the function to do this.

Share this post


Link to post
Share on other sites
header("Location:membersarea.php");

but it will ONLY work if there is nothing sent to the browser before.

Share this post


Link to post
Share on other sites
[!--quoteo(post=377710:date=May 27 2006, 08:48 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 27 2006, 08:48 PM) [snapback]377710[/snapback][/div][div class=\'quotemain\'][!--quotec--]
header("Location:membersarea.php");

but it will ONLY work if there is nothing sent to the browser before.
[/quote]


Hi thanks for your help.

I have tried this, but I am getting this error message:

Warning: Cannot modify header information - headers already sent by (output started at /home/lifenzc/public_html/phppractice/logging.php:13) in /home/lifenzc/public_html/phppractice/logging.php on line 61

----

The problem is I only want it to go to the next page once $username has a value, because that means the login has been verified from the DB.

Here is the script: (It did have html/body/head in it but I took it out)

<?php
session_start( );

session_register("username")
?>







<?php

$conn = mysql_connect("llol","lol","lol");
$db = mysql_select_db("lifenzc_TestDataBase");


$username = $_POST["username"];
$password = $_POST["password"];
$result = MYSQL_QUERY("SELECT * from users WHERE usernames='$username'and password='$password'")
or die ("Name and password not found or not matched");

$worked = mysql_fetch_array($result);

$username = $worked[usernames];
$password = $worked[password];
$email = $worked[email];


$fetch = MYSQL_QUERY("SELECT * from users WHERE usernames='$username'and id != '$password'");

while ( $row2 = mysql_fetch_array($fetch) ) {


$fetched = $row2["usernames"];
$fetched2 = $row2["id"];

}















if ( isset($username) )
{




header("Location:membersarea.php");
}
?>

Share this post


Link to post
Share on other sites
This is the most common error with header(). Read this:

[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63199\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=63199[/a]

Share this post


Link to post
Share on other sites

×

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.