mjurmann Posted July 13, 2007 Share Posted July 13, 2007 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 More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 First off, why would you need it between the <head> tags? I personally have never tried it myself, so I don't know the answer to this one. Once you tell me why you want it there, I would be more than happy to play around with it. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-296974 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 No, above the <head> tags, not between... Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-296975 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 In that case, why do you want the code to be above the tags? I will go test this out and see what happens for me. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-296992 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 <html> <?php $id = $_GET['id']; echo $id; ?> <head> <title></title> </head> <body> </body> </html> I just tried that, and it worked fine for me. It echoed out the $id variable fine. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-296995 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Before the <!DOCTYPE .... Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-296999 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 <?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 =] Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297011 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 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 Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297016 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 Post how you are using the header function. And no, it does not strip the variables. Make sure you are putting the inside of the function in double quotes, not single. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297021 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 <?php $projectID = $_GET['emailProjectID']; $MM_redirectLoginSuccess = "client-project-detail.php?id=$projectID"; header("Location: " . $MM_redirectLoginSuccess ) ?>; Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297023 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 Give this a try: <?php $projectID = $_GET['emailProjectID']; $MM_redirectLoginSuccess = "client-project-detail.php?id=$projectID"; header("Location: $MM_redirectLoginSuccess"); ?> Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297027 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Its still stripping it with the code you provided... http://www.domainname.com/client-project-detail.php?id= That is what is in the URL bar Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297030 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 Try to echo out $projectID, it might not have a value. So make sure you are setting it in the URL too. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297032 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Yep it echoes out just fine up there. The value is 0003... Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297037 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Talk about a nightmare, this makes no sense... Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297038 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 What does $MM_redirectLoginSuccess echo out? Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297040 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 client-project-detail.php?id=0003 Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297043 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 It has to be something with the header...the data in the variables are intact up until the point that it goes to the header... Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297045 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 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. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297047 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 That is strange. I tested on another host and it works fine. Does anyone know if there is something I need to turn on in order for this to work? I host on GoDaddy, both of my domains are hosted on GoDaddy. However, only 1 of them allows me to do this. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297054 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 The only difference is the server it won't work on is SSL. Will that matter? Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297055 Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 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. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297056 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Well, I appreciate your help. Does anyone know if on SSL servers the variable is stripped when using the header function? Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297057 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 I just tested this on the same server but without SSL. It still doesn't work. Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297059 Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 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"); Link to comment https://forums.phpfreaks.com/topic/59749-_get-variable-question/#findComment-297062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.