sendmail.php thank you page.

Permalink
Hi all, Hope you can help.

I have built a contact form within the webpage which posts using an external sendmail.php. I did not build the form within Concrete as I do not want the client to tamper with it.

The form sends fine and I receive the email but once send it can not find the thank you page.

This is my send mail code:

<?php

$message='';
$message .= "Name: ".$_REQUEST['frm_name']. "\r\n";
$message .= "Company: " . $_REQUEST['frm_company']."\r\n";
$message .= "Phone: " . $_REQUEST['frm_phone']."\r\n";
$message .= "Website: " . $_REQUEST['frm_web']."\r\n";
$message .= "Message: " . $_REQUEST['frm_message']."\r\n";
$message .= "How did you hear about us?: " . $_REQUEST['frm_how']."\r\n";



// send the email

mail("email@email.com", "Enquiry from website", $message, "From: $_REQUEST[frm_email]", "-f".$_REQUEST[frm_email]);

header( "Location: thanks.php" );
?>

I have tried putting in the full path but I get the following error:

Fatal error: Using $this when not in object context in fulldirectoryappearshere/thanks.php on line 4

Any ideas of how to get around this?

senshidigital
 
senshidigital replied on at Permalink Reply
senshidigital
just tried using the following:

header( "Location: <?=$this->getThemePath()?>/thanks.php" );

Does not work. hope someone can help.
Tony replied on at Permalink Reply
Tony
Have you installed the thanks.php page as a single page? Can you already access it by going tohttp://yoursite/thanks/ ? Note that you shouldn't need the .php in there. If it is a single page, and not a page type, and if you can't access it, go to the single pages section of the dashboard and add it at the bottom there. Then your link should be:

header("Location: ".View::url('/thanks/'));

The View::url() method will make the link work regardless of whether you have pretty urls turned on. (You may have to include the View class if you're doing this from somewhere strange). Concrete also has a redirect function that you can try. I think it's something like:

$this->redirect('/thanks/');
senshidigital replied on at Permalink Reply
senshidigital
Will give that a go. I'll let you know how I get on.

Thanks!
senshidigital replied on at Permalink Reply
senshidigital
Ok nearly got it working. I made the thankyou.php file into a single page and when I type the url in the browser it displays fine.

The only problem I have is when the form is submitted. I used the following code as you suggested:

<?php

$message='';
$message .= "Name: ".$_REQUEST['frm_name']. "\r\n";
$message .= "Company: " . $_REQUEST['frm_company']."\r\n";
$message .= "Phone: " . $_REQUEST['frm_phone']."\r\n";
$message .= "Website: " . $_REQUEST['frm_web']."\r\n";
$message .= "Message: " . $_REQUEST['frm_message']."\r\n";
$message .= "How did you hear about us?: " . $_REQUEST['frm_how']."\r\n";

// send the email

mail("email@email.com", "Enquiry from website", $message, "From: $_REQUEST[frm_email]", "-f".$_REQUEST[frm_email]);

header("Location: ".View::url('/thankyou/'));
?>

When the form submits I get the following error:

Fatal error: Class 'View' not found in full_url/sendmail.php on line 17

I also tried the redirect function but no joy.

What do you think is causing this?

Just so you know I have the sendmail.php in with the themes folder. The email send OK. Its just this part that is causing problems.

Thanks again for the help.
senshidigital replied on at Permalink Reply
senshidigital
OK now works.

After placing the page into the single pages I just used the original code for the following part:

header( "Location:http://www.fullurl/thankyou"... );

This did the trick.

Thanks for the help! Much Appreciated!
Tony replied on at Permalink Reply
Tony
This should have solved that first error you had.
Loader::library('view');