Hi, I have a php script on my website which allows a user to e-mail their friends and tell them about the site. It works but I would like to improve it and I need a little bit of help in doing so.
I have friend.php which is basically the form:
[code=php]
</head>
<body background=”images/friendbg.gif”>
<form action=”process.php” method=”post” class=”style1″>
<div align=”left”><span class=”style2″> </span>
<table width=”300″ height=”360″ border=”0″>
<tr>
<td height=”49″><div align=”center”><span class=”style4″>Tell a friend about us!</span></div></td>
</tr>
<tr>
<td height=”220″><table width=”300″ border=”0″>
<tr>
<td width=”75″>Name:</td>
<td width=”215″><input type=”text” name=”name” size=”25″ maxlength=”50″ />
</tr>
<tr>
<td>E-Mail:</td>
<td><input type=”text” name=”email” size=”25″ maxlength=”50″ /></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type=”text” name=”subject” size=”25″ maxlength=”100″ /></td>
</tr>
<tr>
<td align=”left” valign=”top”>Text:</td>
<td><textarea name=”text” cols=”19″ rows=”8″></textarea>
</td>
</tr>
</table>
<input type=”submit” name=”submit” value=”Send” /></td>
</tr>
<tr>
<td align=”center” valign=”bottom”><p class=”style6″> </p>
<p class=”style6″> </p>
<p class=”style6″>Copyright © 2006.<br />
All Rights Reserved.</p></td>
</tr>
</table>
<br />
<br />
</div>
</form>
</body>
I also have process.php:
[code=php]
<?php
ob_start();
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>
<body>
<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
if (preg_match(“/^(w[w-.]*)@([w-.]+)$/”,trim($email),$matches)) {
$email = “{$matches[1]}@{$matches[2]}”;
} else {
die(“Sorry there was an error”);
}
$name = preg_replace(array(“/r/”,”/n/”),””,$name);
$subject = preg_replace(array(“/r/”,”/n/”),””,$subject);
mail($email,$subject,$text,”From:$name <‘[email protected]’>”);
header(“location:closefriend.html”);
?>
</body>
</html>
<?php
ob_end_flush();
?>
When the user fills in the form, say using the following:
Name: Gary Roberts
E-mail: [email][email protected]
Subject: Hello
Text: Hi
the e-mail arrives as follows:
[img]
I would like it if the subject stated my e-mail address rather than Hello. I would also like to insert some text in to every e-mail, regardless of what the user types. In my own words I would like to describe my website, then have their message below it
Thanks