I am pretty new to web programming and am trying to get a personal website up and running. I have a contact form which does not seem to execute anything. I have poured over the web looking for the error in my code, but I have hit a wall.
scripts in header
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://html5form.googlecode.com/svn/trunk/jquery.html5form-1.5-min.js"></script>
html5 form
<form action="message.php" method="post" id="message_form">
<fieldset>
<input type="email" name="email" id="email" title="Email address" maxlength="40" placeholder="Email Address" autocomplete="off" required />
<br />
<input type="text" name="subject" id="subject" title="Subject" maxlength="60" placeholder="Subject" autocomplete="off" required />
<br />
<textarea name="message" id="message" title="Message" cols="30" rows="5" maxlength="1000" placeholder="Message" required></textarea>
<br />
<input type="submit" value="Send" id="submit" name="submit"/>
</fieldset>
</form>
script in body (linked)
$('#message_form').html5form({
allBrowsers : true,
responseDiv : '#response',
messages: 'en',
messages: 'es',
method : 'GET',
colorOn :'#0d85a5',
colorOff :'#d2d2d2'
});
message.php
<?php
if ('POST' === $_SERVER['REQUEST_METHOD']) {
$to = "rbblakeley@gmail.com";
$from = "r.blakeley@yahoo.com";
$subject = "test subject";
$message = "test message";
$body = "$from\n $message";
echo "Your message has been sent!";
mail($to, $subject, $body);
} else {
echo "Rapscallions! Please try again.";
}
?>
testing on a local MAMP server and uploading to my remote host (bluehost), nothing happens when I hit ‘send’ except the forms resets to placeholder values. help.
You forgot to give your submit button a name
A better way to do this might be instead of
Use:
This method doesn’t check for a specific variable. It checks the request method and if it’s POST then the form was submitted.