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 Quote Link to comment 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. Quote Link to comment 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... Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Before the <!DOCTYPE .... Quote Link to comment 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 =] Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 ) ?>; Quote Link to comment 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"); ?> Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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... Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 13, 2007 Share Posted July 13, 2007 What does $MM_redirectLoginSuccess echo out? Quote Link to comment Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 client-project-detail.php?id=0003 Quote Link to comment 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... Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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"); 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.