BaconBeast321 Posted May 28, 2006 Share Posted May 28, 2006 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 elseecho("Not logged in!");?>Any help would be awesome! I haven't been able to find the function to do this. Link to comment https://forums.phpfreaks.com/topic/10617-please-tell-me-the-function-name-i-need-lol/ Share on other sites More sharing options...
AndyB Posted May 28, 2006 Share Posted May 28, 2006 header("Location:membersarea.php");but it will ONLY work if there is nothing sent to the browser before. Link to comment https://forums.phpfreaks.com/topic/10617-please-tell-me-the-function-name-i-need-lol/#findComment-39589 Share on other sites More sharing options...
BaconBeast321 Posted May 28, 2006 Author Share Posted May 28, 2006 [!--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)<?phpsession_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 https://forums.phpfreaks.com/topic/10617-please-tell-me-the-function-name-i-need-lol/#findComment-39590 Share on other sites More sharing options...
poirot Posted May 28, 2006 Share Posted May 28, 2006 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 https://forums.phpfreaks.com/topic/10617-please-tell-me-the-function-name-i-need-lol/#findComment-39618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.