Jump to content

Urgent Help: Php form - After clicking submit the page url should direct to other url


jitendra

Recommended Posts

Hello Php Expert,

 

I need help on my current client project. I have made landing page with contact form which is working fine. But after form submission i want the page to redirect to thanks page..

 

http://ebusinessbpo.com/cebucallcenter/index.html

 

After submit it should redirect to this page

 

http://ebusinessbpo.com/cebucallcenter/thankyou.html

 

I have tried many things with using header etc..but still no solutions..plz help its urgent... my code as below...

 

<?php

/* ==============================================
Settings
============================================== */

define("MAILTO" , "[email protected]");
define("SUBJECT" , "xyz- landing page query");

define("ERROR_MESSAGE" , "Error sending your message");
define("SUCCESS_MESSAGE" , "Message Sent");

/* ==============================================
Email Sender    
============================================== */

/* create email message */
$message = '';
    
// Name
$message .= 'Name : ' . $_POST['name'] . "\r\n";

// Email
$message .= 'Email : ' . $_POST['email'] . "\r\n";
    
// Phone
$message .= 'Phone : ' . $_POST['phone'] . "\r\n";

// Address
$message .= 'Address : ' . $_POST['address'] . "\r\n";

// Company
$message .= 'Company : ' . $_POST['company'] . "\r\n";

function validateEmail($email) {
   if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))
      return true;
   else
      return false;
}

if((strlen($_POST['name']) < 1 ) || (strlen($_POST['email']) < 1 ) || validateEmail($_POST['email']) == FALSE ) {

    echo( ERROR_MESSAGE );

} else {

    if( mail( MAILTO , SUBJECT , $message , "From: ".$_POST['name']." <".$_POST['email'].">\r\n" ."Reply-To: ".$_POST['email']."\r\n" ) ) {
        
        echo( SUCCESS_MESSAGE );

    } else {

        echo( ERROR_MESSAGE );

    }

}

?>

instead of 

 echo( SUCCESS_MESSAGE );

use

header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html');

to redirect. Change the URL to wherever you want the page to go.

Hi David,

 

I changed:

 

echo( SUCCESS_MESSAGE );

 

to

 

header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html');

 

The form is submitting but its not redirecting to another url. Also now its validation issue.

 

Please check:http://ebusinessbpo.com/cebucallcenter/index.html

 

Thanks,

Jitendra
 

 

Also now its validation issue.

not sure what the validation issue is.

 

I get no response from the form. when I submit it.

The code

<?php 
header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html');
?>

redirects me. Are you sure you have the line right? If you do, you are not getting to the success message.

 

Please wrap your code in code tags so it doesn't convert urls to links and its readable. (the <> in the editor).

 

BTW: On your form the confirm details checkbox should be removed and the idea that the word details links to nowhere is really bad.

<?php

/* ==============================================
Settings
============================================== */

define("MAILTO" , "[email protected]");
define("SUBJECT" , "ebusinessbpo - landing page query");

define("ERROR_MESSAGE" , "Error sending your message");
define("SUCCESS_MESSAGE" , "Message Sent");

/* ==============================================
Email Sender	
============================================== */

/* create email message */
$message = '';
    
// Name 
$message .= 'Name : ' . $_POST['name'] . "\r\n";

// Email
$message .= 'Email : ' . $_POST['email'] . "\r\n";
	
// Phone
$message .= 'Phone : ' . $_POST['phone'] . "\r\n";

// Address
$message .= 'Address : ' . $_POST['address'] . "\r\n";

// Company
$message .= 'Company : ' . $_POST['company'] . "\r\n";

function validateEmail($email) {
   if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))
	  return true;
   else
	  return false;
}

if((strlen($_POST['name']) < 1 ) || (strlen($_POST['email']) < 1 ) || validateEmail($_POST['email']) == FALSE ) {

	echo( ERROR_MESSAGE );

} else {

	if( mail( MAILTO , SUBJECT , $message , "From: ".$_POST['name']." <".$_POST['email'].">\r\n" ."Reply-To: ".$_POST['email']."\r\n" ) ) {
		
header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html');
	} else {

		echo( ERROR_MESSAGE );

	}

}

?>

I have changed it but still not working...

 

http://ebusinessbpo.com/cebucallcenter/index.html

 

Your contact form is being submit via AJAX using Jquery.post().

 

Using header() in your PHP script wont redirect the user. You need to edit  /js/drn.js to perform the redirect. The code for submitting the form is on line 131 of drn.js, try change it to

$.post(formAction, formData, function(data) {
    window.location.replace('/cebucallcenter/thankyou.html'); // redirect user
});

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.