Jump to content


Photo

Please tell me the function name I need LoL!


  • Please log in to reply
3 replies to this topic

#1 BaconBeast321

BaconBeast321
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 28 May 2006 - 01:43 AM

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.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 28 May 2006 - 01:48 AM

header("Location:membersarea.php");

but it will ONLY work if there is nothing sent to the browser before.
Legend has it that reading the manual never killed anyone.
My site

#3 BaconBeast321

BaconBeast321
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 28 May 2006 - 01:58 AM

[!--quoteo(post=377710:date=May 27 2006, 08:48 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 27 2006, 08:48 PM) View Post[/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");
}
?>

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 28 May 2006 - 03:16 AM

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]
~ D Kuang




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users