asked on
<?php
if (isset($_POST['name']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$errorstring = "";
if (!$name)
$errorstring = $errorstring."Name<br>";
if (!$email)
$errorstring = $errorstring."Email<br>";
if (!$message)
$errorstring = $errorstring."Message<br>";
echo "The length of message is ".strlen($message);
echo "<br>";
if ($errorstring!="")
echo "Please fill out the following fields:<br> $errorstring";
else
{
echo "Success!";
echo "<form action='formvalidation.php' method='POST'>";
echo "</form>";
}
}
?>
<form action="formvalidation.php" method='POST'>
Name: <input type='text' name='name' value='<?php echo $name; ?>'> <br>
Email: <input type='text' name='email' > <br>
Message: <textarea name='message' rows='5' cols='40'> <?php echo $message; ?> </textarea> <br>
<input type="submit" name="click" value='Send'> <br>
</form>
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
note the spaces that exists beside your echo:
Open in new window
Those spaces are actually being produced in HTML, each with a string length of 1.
Try removing them like so:
Open in new window