I'm working on a guestbook for my website. What I have right now is a basic HTML form:
<form action="submit.php" method="post">
Name: <input type="text" value="Julian Davis" name="name"readonly><br>
E-mail (Not published) <input type="text" name="email"><br>
Message: <input name="message" rows="5" cols="40"><br>
<input type="submit">
</form>
(the name field being read-only is part of the gag). It uses HTTP POST to send the results to submit.php, which looks like this:
<?php
if strlen($_POST["message"]) = 0 {
echo "You didn\'t type a message. Don't you want people to hear
what you have to say?";
}
else if strlen($_POST["message"]) > 499 {
echo "Messages are limited to 500 characters. Try again.";
}
else{
echo "Your response has been received. Cheers!";
}
?>
I'm planning to add some SQL queries to aggregate the responses, but first I want this script to not return a blank page.
I haven't written any forms or used POST before (plus, I'm a little shaky on my elseifs), so it's probably some silly syntax thing, but I've looked the script up and down, and I can't see anything wrong with it.
(Also, if anyone has any tips for how to make this form secure, perhaps a CAPTCHA, please let me know!)