|
-
Sep 10th, 2005, 02:18 PM
#1
Thread Starter
Lively Member
Contact Form Creator site
I need a code so people can input things into a form and then when they submit it creates an email form with all the information they typed in like the recieving address and stuff.
-
Sep 11th, 2005, 02:04 AM
#2
Re: Contact Form Creator site
Is this what you mean? It's a sript I wrote a while ago. HTH 
PHP Code:
<script language="javascript">
function validate(theform) {
if (theform.name.value == "") {
alert("Please enter your Name");
return false; }
if (theform.email.value == "") {
alert("Please enter your Email Address");
return false; }
if (theform.comments.value == "") {
alert("Please enter your comments");
return false; }
if (theform.email.value.indexOf ('@',0) == -1 || theform.email.value.indexOf ('.',0) == -1) {
alert("The Email address is invalid");
return false; }
}
</script>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
if (!isset($_POST['submit'])) { // if form hasn't been submitted to itself then show form
?>
<html>
<head>
<title>LintzOnline Feedback Form</title>
</head>
<body><center>
<b><font size="6">Welcome to the LintzOnline Feedback Form</font></b>
<p>
<form method="POST" action="<?php echo $PHP_SELF;?>" onSubmit="return validate(this)">
<table border="1" style="border-collapse: collapse" bordercolor="#111111" width="580">
<tr>
<td width="580">
<table border="0" cellpadding="1" width="100%">
<td width="35%"><font face="Verdana" size="2"><b>Your Name:</b></font></td>
<td width="65%"><input type="text" name="name" size="65"></td>
</tr>
<tr>
<td width="35%"><font face="Verdana" size="2"><b>Email Address:</b></font></td>
<td width="65%"><input type="text" name="email" size="65"></td>
</tr>
<tr>
<td width="35%" valign="top"><font face="Verdana" size="2"><b>Comments:</b></font></td>
<td width="65%"><textarea rows="10" name="comments" cols="50"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><br>
<input type="submit" value="Submit" name="submit" style="font-family: Verdana; font-size: 10pt; font-weight: bold"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<p>
<font size="3" color="black"><a href="https://www.paymate.com.au/PayMate/ExpressPayment?mid=lintz&amt=" target="_blank">
<img src="paymate.gif" border="0\ alt="Donate To LintzOnline" width="88" height="31"></a>
<br>Please support LintzOnline by donating for further script development. <br>
<font size="2" color="blue"><b>Powered by <a target="_blank" href="http://www.lintzonline.com">LintzOnline</a></b></font>
<?
} else {
//This shows the user who has submitted the detials, what details have been submitted.
echo "Thank you <b>$name</b> for submitting the below feedback/comments.<p>";
echo "Feedback/Comments: $comments";
$ToEmail = "[email protected]"; //Set this to the email address you want the feedback emailed to.
$subject = "LintzOnline Form Feedback"; //Set this to the subject of the emaile received after the feedback form has been submitted
$message ="Below are the details of the LintzOnline Feedback Form.
Name: $name
Email: $email
Comments: $comments"; //Set this to what you want to receive in the email sent after the feedback form as been submitted.
$headers = "From: My Website Feedback Form"; //Set this to the name you want displayed as the email received "From"
mail($ToEmail,$subject,$message,$headers); //This sends the email
}
?>
-
Sep 15th, 2005, 01:05 AM
#3
Re: Contact Form Creator site
Here is one more:
PHP Code:
<?php
if ($_POST['action'] == "go") {
session_start();
$name = $_POST['name'];
$email = $_POST['email'];
$content = $_POST['content'];
if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) $alert = "You have entered an invalid email address.";
if ($name == "" OR $email == "" OR $content == "") $alert = "To send a message, please complete all 3 fields.";
if ($_SESSION['mail_count'] >= "3") $alert = "Only 3 messages can be sent per session.";
if (!$alert) {
if (!isset($_SESSION['mail_count'])) $_SESSION['mail_count'] = 0;
$_SESSION['mail_count']++;
$message .= "Name as follows:\n\n";
$message .= "$name\n\n";
$message .= "Email address as follows:\n\n";
$message .= "$email\n\n";
$message .= "Message as follows:\n\n";
$message .= "$content\n\n";
mail("[email protected]", "yourdomain.com Message" , "$message", "From: Website <>");
$name = "";
$email = "";
$content = "";
$alert = "Your message has been sent.";
}
}
?>
<html>
<head>
</head>
<body>
<table align=center cellspacing="0" cellpadding="5" border="1" style="height: 450px; width: 500px; margin-top: 50; border-style:inset;">
<tr><td align="center"><form method=post action="mail.php"><br>
Send me a message<br><br>
your name<br><input type=text style="width: 330px;" name=name value="<?=$name?>" maxlength=50><br><br>
your email address<br><input type=text style="width: 330px;" name=email value="<?=$email?>" maxlength=50><br><br>
your message<br><textarea name="content" rows="6" cols="40"><?=$content?></textarea>
<br><br>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="action" value="go">
</form></td></tr>
</table>
<?php
if ($alert) {
echo "<script type='text/javascript'>
<!--
alert ('$alert');
//-->
</script>";
}
?>
</body></html>
"Imagination is more important than knowledge..."
Albert Einstein
-----------------------------------------------
If my reply helped you then you really were lost, but I still took the time to help, please rate it anyway
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|