Jump to content

Please tell me the function name I need LoL!


BaconBeast321

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.
Link to comment
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");
}
?>
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.