Jump to content


Problem with header location


3 replies to this topic

#1 earth4x

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 11 March 2007 - 08:29 PM

$id = $_GET['id'];
header('location: subject.php?id=$id');
exit;

so... I want this page to redirect to subject.php with $id has id...

only thing is, it doesn't work! it writes in my browser subject.php?id=$id instead of something like sujet.php?id=1

What am I doing wrong? :)

#2 God

    Young Padawan

  • Members
  • Pip
  • 80 posts
  • Gender:Male
  • Location:Australia
  • Interests:You all suck at life. (Mished.net)

Posted 11 March 2007 - 09:13 PM

header('location: subject.php?id=' . $id);

#3 earth4x

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 11 March 2007 - 10:52 PM

View PostGod, on Mar 11 2007, 10:13 PM, said:

header('location: subject.php?id=' . $id);


thanks it worked!

#4 SecondV

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:Kentucky
  • Interests:All things PHP & MySQL :)

Posted 11 March 2007 - 11:18 PM

$id = intval($_GET['id']);
header("Location: subject.php?id=$id");
exit;

You want to make sure you clean user input. Run intval() over the ID.

-SV

Edited by SecondV, 11 March 2007 - 11:19 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users