|
Posted by Sebastian Hansen on 10/01/05 19:20
Hi!
I have made a simple contact form for my website, with the function to
stop the php script to make sure it's not sent before all fields are
filled out.
The script work fine, but if you don't fill out all the fields, the rest
of the html code on the site gets pretty weird. I have tried the die
function and the exit() function, but the same result. The text that
tells that the field needs to be filled out, are showing, but as said,
the html code on the rest of the site gets pretty misplaced.
I also wonder how I can put a link in the echo"" function, so that it
will print a fully functional link?
I have posted the code under. I'm very greatful for any help on this
subject.
** Form.php **
<form name="form1" method="post" action="contact_form_sendmail.php">
<br>
<span class="style1">+</span> Name: <br>
<input name="name" id="name" size="20" style="float: left">
<br>
<br>
<br>
<span class="style1">+</span> E-post: <br>
<input name="mail" id="mail" size="20" style="float: left">
<br>
<br>
<br>
<span class="style1">+</span> Comment: <br>
<textarea name="comment" cols="16" rows="3" id="textarea2"></textarea>
<br>
<input type="image" src="img/contact/button_contact_send.gif"
name="Submit" value="Submit" width="48" height="23" alt="send">
</form>
** contact_form_sendmail.php **
<?
$name = $_POST['name'];
$mail = $_POST['mail'];
$comment = $_POST['comment'];
if(!$name)
{
echo "<b>Name field has to be filled out</b><br>";
die;
}
if(!$mail)
{
echo "<b>E-post field has to be filled out</b><br>";
die;
}
if(!$comment)
{
echo "<b>Comment field has to be filled out</b><br>";
die;
}
mail("mymail@mymail.com", "$name", "$mail", "$comment");
echo "<b>Comment sent!</b>";
?>
[Back to original message]
|