The first part is what goes in the html document as you can see.
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
The code below is the external part of the email
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Obviously I aint good at this sort of thing yet I have only just started to learn PHP but can't get it to send mail which i need for the site i am building. When run it displays the very last tag in the html document.
I know php is server side I have downloaded and configured apache to run with php and downloaded php and configured it to work with apache so all is well there this works as well I ran a test on it.
It is just this code from w3schools that doesn't work. it displays the form also the end tag after the submit button but nothing happens when you click submit.
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
The code below is the external part of the email
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Obviously I aint good at this sort of thing yet I have only just started to learn PHP but can't get it to send mail which i need for the site i am building. When run it displays the very last tag in the html document.
I know php is server side I have downloaded and configured apache to run with php and downloaded php and configured it to work with apache so all is well there this works as well I ran a test on it.
It is just this code from w3schools that doesn't work. it displays the form also the end tag after the submit button but nothing happens when you click submit.