Various Technologies Building Dynamic Web Application – Part II
A Simple PHP mail script :
First, make the form page mail.html (you may call it whatever you like)…
<html>
<head><title>A Mail Sending Program</title></head>
<body>
<form action=”mail.php” method=”POST”>
<b>EMAIL</b><br>
<input type=”text” name=”email” size=40>
<p><b>SUBJECTt</b><br>
<input type=”text” name=”subject” size=40>
<p><b>MESSAGE</b><br>
<textarea cols=30 rows=15 name=”message”></textarea>
<p><input type=”submit” value=” Send “>
</form>
</body>
</html>
The form contains the necessary text fields Email, Subject, Message, and the Send button.
<form action=”mail.php” method=”POST”>
The line tells the browser which PHP file will process the form and what method to use for sending data. When the user fills in the form and hits the Send button, the mail.php file is called…
<html>
<head><title>PHP MAIL SENDING SCRIPT</title></head>
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $HTTP_POST_VARS[’email’];
$subject = $HTTP_POST_VARS[‘subject’];
$message = $HTTP_POST_VARS[‘message’];
/* The script checks that the Email field contains a valid email address and the Subject field isn’t empty.*/
if (!preg_match(“/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/”, $email)) {
echo “<h4>INVALID EMAIL ADDRESS</h4>”;
echo “<a href=’javascript:history.back(1);’>Back</a>”;
} elseif ($subject == “”) {
echo “<h4>NO SUBJECT</h4>”;
echo “<a href=’javascript:history.back(1);’>Back</a>”;
}
elseif (mail($email,$subject,$message)) {
echo “<h4>THANK YOU FOR SENDING EMAIL</h4>”;
} else {
echo “<h4>CAN’ SEND EMAIL TO $email</h4>”;
}
?>
</body>
</html>
Both ASP and PHP have a fairly quick learning curve and can be used to create quite complex sites.When a request for a dynamic web page is received by the server, some intermediate processing must be completed, such as the execution of scripts by the PHP engine. This processing introduces a delay before the web server begins to deliver the output to the browser. This may not be a significant delay where simple PHP scripts are concerned, but for a more complex application, the PHP engine may have a lot of work to do before the page is finally ready for delivery. This extra work results in a noticeable time lag between the user’s requests and the actual display of pages in the browser.
Superb follow up of the previous article @part I.
good job..