I did find this on the Dreamhost wiki, but it’s greek to me:
Is that contact.php?
What about thankyou.php?
And honestly, I’m not sure what FastCGI is either, but see if disabling it (you can always change it back later) changes anything:
https://panel.dreamhost.com/index.cgi?tree=domain.manage¤t_step=Index&next_step=ShowEdithttp
It’s under Web Options -> PHP mode. Change the type to PHP 5.2 CGI, maybe?
The PHP is placed into thankyou.php. contact.php calls it by <form method=“post” action=“thankyou.php”>
So, I’ve tried changing PHP mode to just PHP 5.2, and Dreamhost tells me it’ll take some hours to propagate and go into effect. In any case, it still doesn’t work now.
Is there nothing else in the working thankyou.php on your host? The expected “You have successfully submitted your inquiry. Please allow up to 48 hours for a response.” on a successful submit doesn’t seem to be in the snippet you posted. See if you can do a search for that text across all your files and see where that line comes from.
No, of course, the rest of the HTML is below the script. I posted the script only, as that’s the part that’s malfunctioning. There’s an entire HTML page below it. The thank you page on my host is doing exactly what it’s supposed to do.
Would you mind posting the entire HTML page for thankyou.php, just in case? I’m asking because (as far as I can tell) the script is referencing functions and variables not present in that snippet and I’m trying to see where they’re coming from. It may be a part of the problem.
It’s referencing variables from the form on contact.php.
contact.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Lawston Fown | Actor, Voiceover Artist, Creative Collaborator | David Goodloe</title>
<link href="DG-styles.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/JavaScript" src="includes/validatecontact.js">
</script>
</head>
<body>
<? include("includes/mainnav.php"); ?>
<? include("includes/banner.php"); ?>
<div id="layout">
<div id="content">
<!-- Main copy starts here: edit only between these flags -->
<h1>Contact </h1>
<p>David Goodloe <br />
Agent info here. </p>
<h2>Via Email (<span class="required">»</span> indicates required field)</h2>
<form name="contact" id="contact" action="thankyou.php" method="post" onsubmit="return validate(this)">
<p><span class="required">»</span> Name: <input name="name" id="name" type="text" style="position:relative; left:25px;" /><br />
<span class="required">»</span> Email: <input name="emailaddr" id="emailaddr" type="text" style="position:relative; left:28px;" /><br />
<span class="required">»</span> Phone: <input name="phone" id="phone" type="text" style="position:relative; left:21px;" /></p>
<p><span class="required">»</span> Which service are you interested in?
<select name="service" id="service" style="position:relative; left:49px;">
<option value="" selected>Please select</option>
<option value="Actor">Actor</option>
<option value="Voiceover">Voiceover</option>
<option value="Other">Other</option>
</select>
<br />
How did you hear about me?
<input name="referredby" type="text" id="referredby" style="position:relative; left:118px;" size="19" />
</p>
<p><span class="required">»</span> Message:
<textarea name="messagetext" id="messagetext" cols="30" rows="3" style="position:relative; left:10px; vertical-align:text-top;"></textarea></p>
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean'
};
</script>
<?php
require_once('recaptcha/recaptchalib.php');
$publickey = "public_key_here"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
<input type="submit" value="Submit" style="margin-top:15px; margin-left:150px;" />
</form>
<!-- Main copy ends -->
</div>
<? include("includes/footer.php"); ?>
</div>
</body>
</html>
thankyou.php:
<?php
require_once('recaptcha/recaptchalib.php');
$privatekey = "private_key_here";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if(!$resp->is_valid) {
header("location:captchaerror.php");
die();
} else {
// Your code here to handle a successful verification
$email = "email@email.com";
$continue = "index.php";
// This line prevents values being entered in a URL
if ($HTTP_SERVER_VARS['REQUEST_METHOD'] != "POST"){exit;}
$name = stripslashes($HTTP_POST_VARS['name']);
$emailaddr = $HTTP_POST_VARS['emailaddr'];
$phone = stripslashes($HTTP_POST_VARS['phone']);
$service = stripslashes($HTTP_POST_VARS['service']);
$referredby = stripslashes($HTTP_POST_VARS['referredby']);
$messagetext = stripslashes($HTTP_POST_VARS['messagetext']);
$subject = "Lawston Fown Webform: $service";
$message = "Name: $name
Email Address: $emailaddr
Phone: $phone
Referred by: $referredby
";
$message .= "Which Service?: $service
";
$message .= "Message: $messagetext
";
$headers = "From: " . $emailaddr . "
" . "Return-Path: " . $emailaddr . "
" . "Reply-To: " . $emailaddr . "
";
mail($email,$subject,$message,$headers);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Lawston Fown | Actor, Voiceover Artist, Creative Collaborator | David Goodloe</title>
<link href="DG-styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="media/shadowbox/shadowbox.css" />
</head>
<body>
<? include("includes/mainnav.php"); ?>
<? include("includes/banner.php"); ?>
<div id="layout">
<div id="content">
<!-- Main copy starts here: edit only between these flags -->
<h1>Thank You </h1>
<p>You have successfully submitted your inquiry. Please allow up to 48 hours for a response. </p>
<!-- Main copy ends -->
</div>
<? include("includes/footer.php"); ?>
</div>
</body>
</html>
I’ve munged the personal info (email address, public/private keys), but everything else is as it is. Again, none of the recaptcha code is at issue, on either page. That works fine, I’ve already tested it. It’s just the stuff after
} else {
// Your code here to handle a successful verification
that’s causing problems.
Yay! I figured it out. It has to do with Dreamhost’s PHP configuration, which disables register_long_arrays, a setting that your old script relied on.
To fix the problem, in thankyou.php, replace:
All occurrences of HTTP_SERVER_VARS** with **_SERVER
AND
all occurrences of HTTP_POST_VARS** with **_POST
The fixed snippet should look like:
// This line prevents values being entered in a URL
if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}
$name = stripslashes($_POST['name']);
$emailaddr = $_POST['emailaddr'];
$phone = stripslashes($_POST['phone']);
$service = stripslashes($_POST['service']);
$referredby = stripslashes($_POST['referredby']);
$messagetext = stripslashes($_POST['messagetext']);
ETA: You can re-enable FastCGI now, too. Sorry about that.
You were working on my code at 2am? I’m flattered.
I need to run a bunch of errands, but I’ll try this later today and let you know how it works. Thanks for all your help.
It’s more fun than working on my code at 2am One makes me smile, the other makes me want a sledgehammer.
Yay, it works. It is beeyootiful. Thank you.
I suppose this means I ought to update the other forms using this code now, too.