Hello,
I am trying to work out how to make the following changs to the form as l don't have much knowledge of PHP.
1. Validate each field
2. Display thank you page.
3. Display error page if all fields are not complete.
coding:
<?php
$to="jjr@club-amigos.co.uk ";
if (!isset($_POST["send"])){
// no post data -> display form
?>
<form method="POST" action="<?=$_SERVER['PHP_SELF'];?>">
To: jjr@club-amigos.co.uk
From: <input type="text" name="sender">
Subject : <input type="text" name="subject">
Message :
<textarea name="message" rows="10" cols="60" lines="20"></textarea>
<input type="submit" name="send" value="Send">
</form>
<?
}else{
// found post data .. deal with it
$from=$_POST['sender'];
// send mail :
if (mail($to,$_POST['subject'],$_POST['message'],"From: $from\n")){
// display confirmation message if mail sent successfully
echo "Your mail was indeed sent to $to.
";
}else{
// sending failed, display error message
echo "Doh! Your mail could not be sent.
";
}
}
?>
I am trying to work out how to make the following changs to the form as l don't have much knowledge of PHP.
1. Validate each field
2. Display thank you page.
3. Display error page if all fields are not complete.
coding:
<?php
$to="jjr@club-amigos.co.uk ";
if (!isset($_POST["send"])){
// no post data -> display form
?>
<form method="POST" action="<?=$_SERVER['PHP_SELF'];?>">
To: jjr@club-amigos.co.uk
From: <input type="text" name="sender">
Subject : <input type="text" name="subject">
Message :
<textarea name="message" rows="10" cols="60" lines="20"></textarea>
<input type="submit" name="send" value="Send">
</form>
<?
}else{
// found post data .. deal with it
$from=$_POST['sender'];
// send mail :
if (mail($to,$_POST['subject'],$_POST['message'],"From: $from\n")){
// display confirmation message if mail sent successfully
echo "Your mail was indeed sent to $to.
";
}else{
// sending failed, display error message
echo "Doh! Your mail could not be sent.
";
}
}
?>