PHP Registration form redirect

So I am using a simple PHP contact form as a registration form. it has radio buttons to select the type of payments made. Easch type of payment has a seperate paypal button on a seperate HTML page. What I am trying to do is heve the form, on submit, redirect to the appropriate html page depending on the radio button selected. Does this make sense?

Here is the link to the form page:
http://brand32.com/clients/New%20Philosophers%20Stone/html_theme/workshops.html

and here is the sendreg.php code:

<?php ob_start(); /* CONTACT FORM */ /* Edit the send_to line below */ $send_to = '[email protected]'; /* Do not need to edit anything beyond this line */ /* For more Contact forms, visit CodeCanyon */ $hasErrors = false; // Check if name, email and message are filled out. if(empty($_POST["cf_name"]) || empty($_POST["cf_email"]) || empty($_POST["cf_payment"]) || empty($_POST["cf_message"])) { $hasErrors = true; }else{ // Check if email is a valid email if(preg_match("/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/", $_POST["cf_email"]) == 1) { $hasErrors = false; }else{ $hasErrors = true; } } // email_2 is a HIDDEN dummy field // If this is filled out, it's spam, proceed if it's empty... if(empty($_POST["email_2"])) { if($hasErrors == false) { // Include an excerpt in the subject line $excerpt = " " . substr(stripslashes($_POST["cf_message"]), 0, 20) . "..."; $to = $send_to; // pulled from above to make it easier to edit. $from = $_POST["cf_email"]; $subject = 'Contact Form - ' . $excerpt; $headers = "From: ".$from." \r\n" . "Reply-To: ".$_POST["cf_email"]; $body = "\nContact Form Message:\n\n"; $body .= "From: " . $_POST["cf_name"] . " (".$_POST['cf_email'].")\n"; $body .= "Email: " . $_POST["cf_email"] . "\n"; $body .= "Phone: " . $_POST["cf_phone"] . "\n"; $body .= "Phone: " . $_POST["cf_payment"] . "\n"; $body .= "\nMessage:\n" . stripslashes($_POST["cf_message"]) . "\n\n"; $body .= "IP: ". $_SERVER['REMOTE_ADDR'] . "\n"; $body .= "". $_SERVER['SERVER_NAME'] . "\n"; mail($to,$subject,$body,$headers); } }else{ //email_2 is SPAM } ?>
<?php 
	if( $hasErrors == false ) { 
		header("Location: index.html");
	}else{
		echo "<p style='text-align:center; background:#900; color:#fff; padding:20px; margin:100px;'>There has been an error, please go back and resubmit the form.</p>";
	} 
	
	ob_end_flush();

?>

Thanks in advance. Cheers.

Hi flat,

Suppose a user has completely filled in the form and specified the preferred type of payment. Here’s how you would do the redirection:

In your sendreg.php:

[php]//obtain type of payment
$payment_type=$_POST[“cf_payment”];
//if success
Header(‘Location: thankyou.php&p_type=’ . $payment_type);[/php]

(Notice I pass the payment type in the URL so you don’t need to create multiple landing/redirection pages)

In your thankyou.php page, just get the value of $p_type and use ifelse to execute different statements.

Cheers.

Hey,

Thanks codeguru.

I guess what i need is for the “redirect” to send to fullpayment.html if "Full Payment is checked, twopayments.html if “Two Payments” is checked, and fourpayments.html if “Four Payemnts” is checked.

Hope this helps clarify.

Flatrabbit

Sponsor our Newsletter | Privacy Policy | Terms of Service