rlb1
asked on
How do I make this Refresh work when processing a form
Experts,
How do I make the 'Refresh' function work and go to the desired URL after processing a form script. Everything works on the script except for the refresh. (This same script with refresh works just fine on another script)
When I run the script, I get the following information in the returned data from my echo statements:
2
02-23-2011
Sample Comment
2
This is the only thing not working on the page:
header("Refresh: 0;url=http://www.url.com/NewSite/seniorwatch_viewrecord.php?id='".$id."'");
Thanks for your help!
How do I make the 'Refresh' function work and go to the desired URL after processing a form script. Everything works on the script except for the refresh. (This same script with refresh works just fine on another script)
When I run the script, I get the following information in the returned data from my echo statements:
2
02-23-2011
Sample Comment
2
This is the only thing not working on the page:
header("Refresh: 0;url=http://www.url.com/NewSite/seniorwatch_viewrecord.php?id='".$id."'");
Thanks for your help!
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Date');
pt_register('POST','id');
pt_register('POST','comment');
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Date: ".$Date."
Date: ".$Date."
ID: ".$id."
Notes: ".$comment."
";
$message = stripslashes($message);
echo $id;
echo $Date;
echo $comment;
mail("my_email","Org",$message,"From: Me");
$link = mysql_connect("HOST","UN","PW");
mysql_select_db("DB",$link);
$query="INSERT into `comments` (id, comment, Date) values ('".$id."','".$comment."','".$Date."')";
mysql_query($query);
header("Refresh: 0;url=http://www.url.com/NewSite/seniorwatch_viewrecord.php?id='".$id."'");
echo $id;
}
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the number in the content section is how many seconds before the page is refreshed
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The above will work with single quotes in the url too if they are required for some reason.
You will have problems sending headers if you break the string (ie where the " are) - you should always keep the whole header to one set of single quotes and drop any variables in inside them.
You will have problems sending headers if you break the string (ie where the " are) - you should always keep the whole header to one set of single quotes and drop any variables in inside them.
ASKER
Thanks Matthew P! It worked great!