Help Please, I'm going Bat-Shit Crazy with PHP Code

~ Technical Help, Hardware, Programming, Computer Games etc

Moderator: Staff

Post Reply
User avatar
Bootsy Collins
Lost Soul
Posts: 40
Joined: Wed May 16, 2012 6:42 am

Help Please, I'm going Bat-Shit Crazy with PHP Code

Post by Bootsy Collins » Mon Jul 09, 2012 4:01 pm

OK...PHP Code #2.

The email sends, the form works.
What doesn't work is when it gets directed to the feedback.php file (below) it doesn't redirect to the appropriate files.
I've tried clearing all the waste space, I've googled every problem and tried my best to debug it but it still won't go. My server is fine b/c the other php file for email contact works fine.
It might have something to do with the Recaptcha but I doubt it.

Help....I'm pulling what little hair I have left out. The code is exactly as it appears in the file.

Code: Select all

<?php
$mailto = 'info@simcoeparents.com' ;
$subject = "Contest Entry" ;
$errorurl = "http://www.simcoeparents.com/Site/Contest/error.html" ;
$thankyouurl = "http://www.simcoeparents.com/Site/thank-you.html" ;
$formurl = "http://www.simcoeparents.com/Site/Contest/Contest.html" ;
$email_is_required = 1;
$name_is_required = 1;
$comments_is_required = 1;
$uself = 0;
$forcelf = 0;
$use_envsender = 0;
$use_sendmailfrom = 0;
$smtp_server_win = '' ;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$my_recaptcha_private_key = '6LeFtdMSAAAAAADWZMiYINE6uPMaj8y-q45aRsjx' ;

// -------------------- END OF CONFIGURABLE SECTION ---------------

define( 'MAX_LINE_LENGTH', 998 );
$headersep = $uself ? "\n" : "\r\n" ;
$content_nl = $forcelf ? "\n" : (defined('PHP_EOL') ? PHP_EOL : "\n") ;
$content_type = $use_utf8 ? 'Content-Type: text/plain; charset="utf-8"' : 'Content-Type: text/plain; charset="iso-8859-1"' ;
if ($use_sendmailfrom) {
	ini_set( 'sendmail_from', $mailto );
}
if (strlen($smtp_server_win)) {
	ini_set( 'SMTP', $smtp_server_win );
}
$envsender = "-f$mailto" ;
$fullname = isset($_POST['fullname']) ? $_POST['fullname'] : $_POST['name'] ;
$email = $_POST['email'] ;
$qone = $_POST['qone'];
$qtwo = $_POST['qtwo'];
$qthree = $_POST['qthree'];
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header("Location: $formurl");
	exit ;
}
if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {
header("Location: $errorurl");
	exit ;
}
if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {
header("Location: $errorurl");
	exit ;
}
if (strlen( $my_recaptcha_private_key )) {
	require_once( 'recaptchalib.php' );
	$resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
	if (!$resp->is_valid) {
header("Location: $errorurl");
		exit ;
	}
}
if (empty($email)) {
	$email = $mailto ;
}
$fromemail = $use_webmaster_email_for_from ? $mailto : $email ;
if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
	$comments = stripslashes( $comments );
}
$messageproper =
	"This message was sent from:" . $content_nl .
	"$http_referrer" . $content_nl .
	"------------------------------------------------------------" . $content_nl .
	"Name of sender: $fullname" . $content_nl .
	"Email of sender: $email" . $content_nl .
	"Age : $qone" . $content_nl .
	"Children : $qtwo" . $content_nl .
	"Auctions : $qthree" . $content_nl .	
	"------------------------- COMMENTS -------------------------" . $content_nl . $content_nl .
	wordwrap( $comments, MAX_LINE_LENGTH, $content_nl, true ) . $content_nl . $content_nl .
	"------------------------------------------------------------" . $content_nl ;
$headers =
	"From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.2" .
	$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
if ($use_envsender) {
	mail($mailto, $subject, $messageproper, $headers, $envsender );
}
else {
	mail($mailto, $subject, $messageproper, $headers );
}
header("Location: $thankyouurl");
exit ;
?>
Feline Freedom Alliance
Former Pyro of MUM, DOW, SA

User avatar
Bootsy Collins
Lost Soul
Posts: 40
Joined: Wed May 16, 2012 6:42 am

Re: Help Please, I'm going Bat-Shit Crazy with PHP Code

Post by Bootsy Collins » Tue Jul 10, 2012 5:12 am

NVM...Got it figured out.

Now I know why I never went into coding out of highschool.
Feline Freedom Alliance
Former Pyro of MUM, DOW, SA

User avatar
Kaz
Administrator
Posts: 2614
Joined: Thu Sep 24, 2009 1:27 am
Location: The Vinyards of Fernabergia
Tempers Ball Posts: 3873
Tempers Ball/Braggarts Hall Alt: Kaz
Contact:

Re: Help Please, I'm going Bat-Shit Crazy with PHP Code

Post by Kaz » Tue Jul 10, 2012 11:30 am

I think you've made that a lot more complicated that you needed to, but glad it's working now
Programming is 10% science, 25% ingenuity and 65% getting the ingenuity to work with the science
Wars of Tonan (Monarchy Inspired Miniatures)
Armatures for Sculpting Miniatures

User avatar
Bootsy Collins
Lost Soul
Posts: 40
Joined: Wed May 16, 2012 6:42 am

Re: Help Please, I'm going Bat-Shit Crazy with PHP Code

Post by Bootsy Collins » Tue Jul 10, 2012 3:38 pm

I did...that was a secondary one for another form. I slimmed it down and now it's working fine.

Trail and error, the whole learning process.
Feline Freedom Alliance
Former Pyro of MUM, DOW, SA

Post Reply

Return to “Technical Corner”

Who is online

Users browsing this forum: No registered users and 12 guests