I'm using a script I found from dhtml goodies to make a simple html window appear over my site. All I want is a simple form, and I want to add spam protection for obvious reasons. Basically when you click on the link it creates a pop-up window and pulls the file infoform2.php. I've used reCAPTCHA with no problem before, but for some reason it won't display in the window. just to make sure it wasn't a file location problem, I copied/pasted the includes file for reCAPTCHA into infoform2.php.
index.php (the main page where the link is)
infoform2.php (this displays just fine when you view the page by itself, but within the AJAX window it doesn't workHTML Code:<div id="moreinfo"><a href="#" onclick="displayMessage('<?=$siteroot?>moreinfo/infoform2.php');return false">MORE<br />INFO ››</a></div>
PHP Code:<?
##################
#### TEMPLATE ####
##################
function makeheader() { //will house the header etc
//echo "template template template template template template <br><br>";
$pagetitle="Your Opinions";
//$pageident="opinions";
include('../header2.php');
}
function makefooter() {
include('../footer.php');
}
function submitinfo() { //processes the form submission
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$to = "cnurotaract@gmail.com";
$subject = "Someone is interested in CNU Rotaract!";
$message = "Make sure you contact them ASAP! Here's their info:\n\n<b>Name:</b> $name\n<b>Email:</b> $email\nPhone: $phone\n\nGenerated from www.cnurotaract.com";
$from = "membership@cnurotaract.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
require_once('recaptchalib.php');
$privatekey = "6Ld9cwIAAAAAAH8PI1-EnE2w3k3wZsOdmA1KbOKx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
#comment out the if statement for testing purposes
/*if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}*/
?>
<h3>Thanks, <?=$name?>! Your address "<?=$email?>" has been submitted. We'll be in touch shortly!</h3>
<?
}
###################################################################################################
###################################### HOME #######################################################
###################################################################################################
function home() {
//include('opinions/config.php');?>
<html><head><title></title></head>
<form method="post" action="moreinfo/infoform2.php?submitinfo" onsubmit="return submitinfo()" name="moreinfo" class="moreinfo" id="moreinfo">
<!--<form class="moreinfo" id="moreinfo" method="post" action="process.php">-->
<table cols="2">
<tr><td width="30%"><b>Name:</b></td><td width="70%"><input type="text" name="name" id="name" /></td></tr>
<tr><td width="30%"><b>E-Mail:</b></td><td width="70%"><input type="text" name="email" id="email" /></td></tr>
<tr><td width="30%"><b>Phone:</b></td><td width="70%"><input type="text" name="phone" id="phone" /></td></tr>
<tr><td width="30%"><b>Spam Protection:</b></td><td width="70%">
<?
//require_once('recaptchalib.php');
// recaptchalib.php
/* the reCAPTCH stuff is here, i took it out because it's too long for the forum*/
$publickey = "6Ld9cwIAAAAAAEZBAzRayp2tJLYScEt-rzJ2ZX7T"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
reCAPTCHA should be above.
</td></tr>
<tr><td></td><td><input type="button" value="Close" onclick="closeMessage()" /><input type="submit" value="Send" /></td></tr>
</table>
</form>
</html>
<?
}
###########################
#######SWITCH BOARD########
###########################
switch ($_SERVER['QUERY_STRING']) {
case 'submitinfo':
makeheader();
submitinfo();
makefooter();
break;
default:
if($_SERVER['QUERY_STRING'] == 0){
//$section='1';
home();
break;
}
}


Reply With Quote
Bookmarks