Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header(Location:otherpage.php?variable=data) 1

Status
Not open for further replies.

ftsw

Technical User
Sep 17, 2002
9
0
0
US
I have a 2 page script. F is the form script and V will validate the data that the form sends it and insert the data into mysql database. I use the Header(Location:) code to bring a variable called message(it is an error message) back to the F script. $message shows up in the URL and the monitor shows the form but I can not even echo $message in my F script. Any suggestions?
thank you ftsw
 
Your most likely problem is that register_globals is off.

It is considered best practice to leave this off.

You will need to use the super globals $_GET["message"] or $_POST["message] according to the way your script gets its data.

See here for more info.

[smurf]
01101000011000010110010001110011
 
register globals is turned on. Thank you for the good thought and advise. Are there other ideas to solve the problem? Doesn't header(Location:place.php?var=data) move the var=data into the place script and not just listed in the url?
 

SCRIPT F
<html>
<head>
<title>Welcome to UNF Comments Page</title>
</head>
<body>

<?php
//File:comment_form.html
//Displays a comment form.
?>

<form method=&quot;POST&quot; action=&quot;comment.php&quot;>
The rest is the html code for text boxes, drop down boxes, radio buttons and closing the above tags.
<tr>
<td width=&quot;23%&quot; height=&quot;23&quot;>Name:&nbsp;&nbsp;&nbsp;</td>
<td width=&quot;43%&quot; height=&quot;23&quot; colspan=&quot;2&quot;>
<input type=&quot;text&quot; name=&quot;com_name&quot;size=&quot;50&quot;> </td> </tr>

<?php
echo”$message”;
?>

**********************************************************
SCRIPT V
<?php
//File:comment.php
//Validates and inserts data when the user types information into the comment_ form.html

if(!ereg(&quot;^[A-Za-z' -]{1,30}$&quot;,$com_name))
{
header(“Location:comment_form.html?message= Sorry you mistyped your name”);
exit();
}
then other error checking and insert into database.
?>

I hope I wrote enough of the code to answer my question.
 
Reformat the URL you're using in your invocation of header(). Since spaces aren't allowed in URLs, all those spaces are stopping PHP from parsing the value.

Change it to something like:

header(&quot;Location:comment_form.html?message=Sorry+you+mistyped+your+name&quot;);
______________________________________________________________________
TANSTAAFL!
 
Thank you, but I tried no spaces and still does not work.
header(“Location:comment_form.html?message=hello”);
and register_globals is on.
All good ideas, can someone help?
 
Try
Code:
header(“Location: /comment_form.html?message=hello”);
//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top