The form lives at fictiveapp.com/ It's the second one with Name, Email, and Message.
I'm running into two issues.
405 error - I 'resolved' this by adding a trailing slash
404 error - when adding the trailing slash to resolve the previous issue i get a 404 error instead. I'm very new to PHP and am unsure how I'm supposed to link the files. I thought it would be the same as linking all other html files on a site, apparently not.
I have all the index.html, html_form_send.php, and contactthanks.php all in the same top (1st) level directory, with 2nd level CSS, JS, Font, and Img folders
All relavent code is below
HTML
<div class="8u 12u$(small)">
<form name="htmlform" method="post" action="html_form_send.php">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)"><input type="text" name="name" id="name" placeholder="Name" /></div>
<div class="6u$ 12u$(xsmall)"><input type="email" name="email" id="email" placeholder="Email" /></div>
<div class="12u$"><textarea name="message" id="message" placeholder="Message" rows="4"></textarea></div>
</div>
<ul class="actions">
<li><input type="submit" value="Send Message" /></li>
</ul>
</div>
</form>
PHP from html_form_send.php
<?php
$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "from fictive site";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php/\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
PHP from contactthanks.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<head>
<title>work already!</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="page-wrap">
<br /><br />
<h1>Your message has been sent!</h1><br />
<p><a href="index.html">Back to Site</a></p>
</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-68528-29";
urchinTracker();
</script>
I'm sure its something stupid and simple but I've been searching forums for hours now and can't seem to find the issue.
Thanks for any help with this.
When redirecting, headers are better than html meta tags. Keep in mind that you can use an header only when you haven't printed anything.
Here how you can use headers:
header("location: ./yourfile.html");
Also, some tips to create a correct file path
To redirect to a file in the same folder use "./filename.php"
To redirect to a file that is in an external directory you can use "../" to exit 1 dir. for example if my file is inside "/hello/file.php" and I wanna redirect to "/index.php" my path will be "../index.php"