The full code is on that website at the bottom. I don't know where the problem is exactly in the code, so that's why I've put the whole one. I will also paste the part I think I'm having problem with.
The only thing I'm changing is email address to send feedback. It's help@polineng.tk but I'm having a problem with finding a file(site) with thank you or error message after hitting 'submit' button.
Structure looks like this:
/public_html/
/eng/
/eng/feedback/
/eng/feedback/feedback_form.html
/eng/feedback/thank_you.html
/eng/feedback/error_message.html
/eng/feedback/send_mail.php
/eng/uk.html
index.html
When all files from 'feedback' folder are directly in the root folder it works fine, but when it's in sub-folders (like above) script is not finding any files and not sending the email to my inbox.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Feedback Form</title>
</head>
<body>
<h1>Send Us Your Feedback!</h1>
<form action="send_mail.php" method="post">
(...) // structure of the form is not important, so I cut it out
<input type="submit" value="Submit" />
</form>
</body>
</html>
Like I said, this script is not finding I think the problem is with this part:
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;
(...)
// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
Here is the whole script. It's a bit different than the one on the website I gave in the first post.
<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "help@polineng.tk";
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}
// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}
// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}
// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( "$webmaster_email", "Feedback Form Results",
$comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>
Now I also don't know why the feedback is not send too. Is the script not doing anything else after not finding the file or the 'submit' button on my website is not even finding the script (file send_mail.php)