- Impact
- 0
Ok this may sound like a silly question but I have written up a PHP form script which when filled out:
Sends the information in the form fields to the webmaster.
Sends an email to the person who filled out the form telling them it has been successfully filled out.
Ok well that part of it is fine. The problem is when someone visits the page it sends a blank form to the webmaster as if they already hit submit before they filled anything out. If anyone has a solution to this please post here. Here is my script:
BTW: If that looks really silly or anything it's because I learned PHP today LOL. It's pretty simple though. Next I'm going to PHP with mySQL.
Sends the information in the form fields to the webmaster.
Sends an email to the person who filled out the form telling them it has been successfully filled out.
Ok well that part of it is fine. The problem is when someone visits the page it sends a blank form to the webmaster as if they already hit submit before they filled anything out. If anyone has a solution to this please post here. Here is my script:
PHP:
<form action="mail.php" method="get">
Your Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br><br>
Comments<br>
<textarea name="comments"></textarea><br><br>
<input type="submit" value="Submit">
</form>
<?
// PHP Script and form written by Alpha.
$name=$_GET['name'];
$email=$_GET['email'];
$comments=$_GET['comments'];
$to="[email protected]";
$message="$name just filled in your comments form. They said:n$commentsnnTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $emailn")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
mail($email,"Email Sent","Your email to the webmaster has been successfully sent. Thank you for the mail!","From: [email][email protected][/email]n");
?>
BTW: If that looks really silly or anything it's because I learned PHP today LOL. It's pretty simple though. Next I'm going to PHP with mySQL.