Reputation: 45
I am trying to migrate our site to a new host that uses PHP5. Previously we were on PHP4.
I have a form that is not submitting and redirecting to the thankyou page after a user fills out a survey which worked previously on php4. I'm sure it's probably something obvious that I'm missing but I can't see why it doesn't work.
When I click submit, the survey page reloads, the URL gets ?submit=t added to the end and the email is not sent to me.
The code from our survey.php is shown below with my email address and most of the HTML form feilds removed. Can somebody point me in the right direction?
Thanks!
<?
$APP_ROOT = "../";
$FILE = __FILE__;
$TITLE="Service Survey";
if(!isset($submit)) {
include($APP_ROOT."include/header.php");
include($APP_ROOT."include/nava.php");
?>
<div class="bodymargin">
<img src="<?=$WEB_ROOT;?>images/titles/<?=$SECTION."_".$FILE;?>.gif" width="400" height="36"><br>
<br>
<form method="POST" action="<?=$FILE;?>.php?submit=t">
<?
if(isset($error)) {
while(list($key, $value) = each($HTTP_GET_VARS)) {
$$key = stripslashes($value);
}
print("<p class=\"alert\">". urldecode($error) . "</p>\n");
}
?>
<input type="text" name="name" value="<?=$name;?>">
</form>
<?
include($APP_ROOT."include/navb.php");
include($APP_ROOT."include/footer.php");
} else {
include_once($APP_ROOT . "functions/index.php");
include_once($APP_ROOT . "functions/form_validation.php");
$CONTINUE = TRUE;
$valid = new Validation($HTTP_POST_VARS);
if($CONTINUE = $valid->success) {
$to = "myemailaddress";
$subject = "Service Survey";
$from_email = $to;
$from_name = "mysite.com";
$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$email>\n";
$headers .= "Return-Path: <$from_email>\n";
$body = "The following information was just posted \n";
unset($HTTP_POST_VARS['required_fields']);
reset($HTTP_POST_VARS);
while(list($key, $value) = each($HTTP_POST_VARS)) {
if(!empty($value)) {
$body .= proper_form($key) . ": " . stripslashes($value) ."\n";
}
}
$body .= "\nThis is an automated message, please do not respond.";
mail($to,$subject,$body,$headers);
$URL = $WEB_ROOT . "/customer/thanks.php?form=" . $FILE;
server_redirector($URL);
} else {
while(list($key, $value) = each($HTTP_POST_VARS)) {
$rebound .= "&$key=" . urlencode(stripslashes($value));
}
$URL = $WEB_ROOT . "customer/survey.php?error=". urlencode(nl2br($valid->errors)) . $rebound;
server_redirector($URL);
die();
}
}
?>
Upvotes: 0
Views: 171
Reputation: 316
$HTTP_POST_VARS is deprecated. You will want to replace it with $_POST.
Alternatively, you can just add $HTTP_POST_VARS = $_POST; at the beginning of the script to avoid editing every line (Not really recommended).
Upvotes: 0
Reputation: 1882
regsiter_globals
is not active in newer PHP versions.
So instead of using if(!isset($submit))
you have to use if(!isset($_GET['submit']))
. And for posted values, you use $_POST['parameter']
.
Upvotes: 1
Reputation: 6840
The __FILE__
constant is possibly not returning what you expect, or not what it previously did. from the docs
Since PHP 4.0.2, __ FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.
So you may be getting an absolute path now, instead of a relative one.
Also check if your new installation allows for short_open_tags
as explained in the docs
Upvotes: 0