Using .htaccess 












Using .htaccess/.htpasswd Password Protection 


php5
php5
Coding Tips 






Uploads and Downloads 

php5
php5
php5
Mail 



php5


Working with Images 


Frequently Requested Website Functionality 
php5
php5

php5 see it on this page
php5








Using PHP 
php5
php5
php5


Website Managment 







php5

php5
Other Tips 







Form Mail
Here is a simple Form Mail script. It can be used on your website for people sending you messages, rather than using an email link. The script provides a form with name, email address, and message. It validates the email address format. It also provides some protection against mail bombing by only allowing 3 messages to be sent from a single browser session. You can easily modify the script to fit the theme of your site, or change the form.
<?php
// modify the three lines below
$htmlMail = "no"; // "yes" to send html mail - otherwise sends text mail
$emailAddress = "mail@domain.com"; // your email address
$thankyouPage = ""; // leave empty to return to the form after a message has been sent - put in a url (or relative page) to go to a Thank You page
// modify the three lines above
session_start();
if (isset($_POST['send']) AND isset($_SESSION['mail_count'])) {
if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $_POST['email'])) $alert = "You have entered an invalid email address.";
if ($_SESSION['mail_count'] >= "3") $alert = "Only 3 messages can be sent per session.";
if (empty($alert)) {
$_SESSION['mail_count']++;
if (!get_magic_quotes_gpc()) foreach ($_POST as $key=>$value) $_POST[$key] = addslashes($_POST[$key]);
foreach ($_POST as $key=>$value) $_POST[$key] = wordwrap($_POST[$key],65);
if ($htmlMail == "yes") {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = "<table border='1'>";
foreach ($_POST as $key => $value) if (!preg_match("(^send)", $key)) $message .="<tr><td><b>$key</b></td><td>$value</td></tr>";
$message .= "</table>";
} else {
foreach ($_POST as $key => $value) if (!preg_match("(^send)", $key)) $message .= $key . "->\n " . $value . "\n\n";
}
$subject = $_SERVER['HTTP_HOST'] . " Message";
$headers .= "From: <" . $_POST['email'] . ">\r\n";
mail($emailAddress,$subject,$message,$headers);
if (!empty($thankyouPage)) {
header('location: ' . $thankyouPage);
die();
}
unset($_POST);
$alert = "Your message has been sent.";
}
}
if (!isset($_SESSION['mail_count'])) $_SESSION['mail_count'] = 0;
?>
<html>
<head>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<div style="text-align: center; height: 450px; width: 500px; margin-top: 50; border: solid 1px black;">
<br>
Send me a message<br><br>
your name<br><input type="text" style="width: 330px;" name="name" value="<?php echo $_POST['name']; ?>" maxlength="50"><br><br>
your email address<br><input type="text" style="width: 330px;" name="email" value="<?php echo $_POST['email']; ?>" maxlength="50"><br><br>
your message<br><textarea name="content" style="width: 330px; height: 100px;" rows="6" cols="80"><?php echo $_POST['content']; ?></textarea>
<br><br>
<input type="submit" name="send" value="submit">
</div>
</form>
<?php if (isset($alert)) echo "<script type='text/javascript'>alert('$alert');</script>"; ?>
</body></html>