corillo181 Posted January 21, 2007 Share Posted January 21, 2007 why doesn't it go back to the $from page?<?php Check User Script session_start();include '../includes/db.php';$from=$_SERVER['HTTP_REFERER'];$username = $_POST['username'];$password = $_POST['password'];// check if the user info validates the db$sql = mysql_query();$login_check = mysql_num_rows($sql);if($login_check > 0){ while($row = mysql_fetch_array($sql)){$username=$row['username'];$password=$row['password'];$user_id=$row['user_id'];$level=$row['level']; // Register some session variables! $_SESSION['username'] = $username; $_SESSION['password'] = $password; $_SESSION['user_id'] = $user_id; $_SESSION['level'] = $level; mysql_query(""); header('Location:'.$from); }}?> Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 Check the from variable make sure it is sending information, also make sure that it has header('Location:'.$from); rewritten likeheader("Location: $from");That is seemingly more efficient for me, give it a try.Hope that helps. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Author Share Posted January 21, 2007 nah it dont work Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 [quote]<?php Check User Scriptsession_start();[/quote]Looking it that, it's probably telling you headers already sent.You can't have a space between the <?php and hte session_start. Fix that, adn try it again. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Author Share Posted January 21, 2007 i dont think thats the problem becuase when i execute the value of $from it shows where ever i'm coming from.. but it just doesn't work in the header location Quote Link to comment Share on other sites More sharing options...
448191 Posted January 21, 2007 Share Posted January 21, 2007 Euh.. Souldn't you be executing a query?$sql = mysql_query[b]()[/b];There are more errors in your code, maybe you should try switching on error reporting... ;)[code=php:0]error_reporting(E_ALL);[/code] Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Author Share Posted January 21, 2007 everything works fine .. i just deleted everything that has nothing todo with the header i dont want to be showing all my code..everything work fine when i put a addres in header('location..home.php') it works.. i was trrying to change it to go back to the page where the user signs in from..wich should be http_referer but i dont know it doesn't work. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 Did you turn on error reporting though? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Author Share Posted January 21, 2007 yes.. everything is working fine.. just that i had the header set up to send people to the home page but now i got a few more pages and i want them to be sent to the page they was viewing before they sing in.. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 so...now you're saying it was sending to the home page, but you want to send it to a different page? That isn't hard to do, just change the page. But that's not what you had in your first post. Can you explain the problem a little clearer please? Try printing $from to the screen to see what it says? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Author Share Posted January 21, 2007 [code]ok.. i got 3 pages.. the user can sign in from any of them..$from=$_server[http_referer];if statement{header('location:'.$from);or header("location:$from");none of then work it stays on the same page}but if i echo $from it shows the page from wich i'm trying to sing in from..[/code] Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 See that is the point, http referrer pulls the entire url they came from. If you want to go back to the last page on your site, use split on http referrer, to get the exact folder location you want to send them to.It's also not always 100% accurate.I saw your last post, what page is it sending them to.Echo here EXACTLY what the from field is outputting, and show th eoutput on the page, does it give you an error.If it comes up with a blank page, it's an error, if it's sending you somewhere specific, where as opposed to where is it suppose to send you. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 Location has to be capitalized, I think.Can you show me what $from prints out? Perhaps it's a path issue? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 21, 2007 Author Share Posted January 21, 2007 i know the problme i had to put a if statement for the $from.. too just in case the user has wrong password and the referer would be the same page..so if the referer is the same page than just go to index page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.