Jump to content

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


jitendra
Go to solution Solved by Ch0cu3r,

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" , "jj@xyz.com");
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 );

    }

}

?>

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

<?php

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

define("MAILTO" , "jsurve@in.ebusinessbpo.com");
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

 

Link to comment
Share on other sites

  • Solution

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
});
Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.