Jump to content

header direction


corillo181

Recommended Posts

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

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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

[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]
Link to comment
Share on other sites

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.
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.