Jump to content

$_GET variable question


mjurmann

Recommended Posts

Is it possible to take a variable from a URL such as admin-home.php?id=001 where 001 is the data from the id variable and then perform a series of conditional statements before the <head></head> tags. It seems that when I try to $_GET['id'] in the area before the <head> </head> tags the id variable is null. However, when I echo that same variable out in the body, the id echoes out correctly.

 

Simple question...anyone?

 

Thanks so much

Link to comment
https://forums.phpfreaks.com/topic/59749-_get-variable-question/
Share on other sites

<?php

$id = $_GET['id'];
echo $id;

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title></title>
  </head>
  <body>

  </body>
</html>

 

Still worked for me =]

 

Yes it works. I tested it.

 

It must be the header ( function. I pass the variable in the header.

 

Does anyone know if the header strips all variables and if so, is there a way around this?

 

I'm trying to let people log in and then be directed to a project page with the specific project id that was in the initial URL. The variable carries through fine but seems to get lost in the header ( function

Thats strange, I did my own test on my own server, and everything worked out fine....

 

<?php

$id = $_GET['id'];
$new_url = "help.php?test=$id";

header("Location: $new_url");

?>

 

I don't see anything different about your code...so I have no idea what is going on.

If it works on your other GoDadding account, I would say it isn't a problem with the server.

 

Try putting

error_reporting(E_ALL);

 

at the top of your script.

 

EDIT: I have no idea if the SSL server will effect anything. I guess we will have to wait until someone else comes along that can answer that.

Error reporting results:

 

Notice: Undefined index: emailProjectID in /home/content/m/j/u/mjurmann/html/client-login-note.php on line 14

 

Line 14 has: $projectID = $_GET['emailProjectID']; 

 

Aslo:

 

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/j/u/mjurmann/html/client-login-note.php:14) in /home/content/m/j/u/mjurmann/html/client-login-note.php on line 46

 

 

Line 14 has: $projectID = $_GET['emailProjectID']; 

Line 46 has:  header("Location: $MM_redirectLoginSuccess");

 

 

Archived

This topic is now archived and is closed to further replies.

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