PDA

View Full Version : Contact Us Form



lasor
08-23-2004, 07:37 AM
Hi All

I am looking for another contact form. NOT the one for listingview. (I am already using that one) This one I need for my contacts page so that I dont have to put the email address on display and open it up to email harvesters. I just want a basic form except I want the subject to be an option field so the user can select the relavent subject. Does anybody have a script available for download.

Lasor

marb
08-23-2004, 11:40 AM
This have the options you want.
Found it a time ago on hotscripts to use with the OR script.
But dont have install it myself (have no time for it), you can try it.
Its under GPL.
I'm not the author.

Groeten,
Marten :)

lasor
08-23-2004, 01:19 PM
Thanks Marb

I have now found another easier form it is just missing the drop down option list. If anybody could tell me how to add a simple subject dropdown option list to this code I would be grateful.

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?><b><font color="#42557B">Your Name:</font></b> <input type=text name="visitor" size="35">
<br>
<b><font color="#42557B">Your Email:</font></b> <input type=text name="visitormail" size="35">
<br><br>
<b><font color="#42557B">Mail Message:</font></b>
<br>
<textarea name=notes rows=4 cols=40></textarea>
<br>
<input type=submit VALUE="Send Mail">
<br>
&nbsp;</form>

This is just the section of the form that displays the fields.

Lasor

marb
08-23-2004, 02:11 PM
Perhaps you like this??????

See a example here;
http://javascript.internet.com/forms/mail-pick-subject.html

You can put also a part of this script ( the select box) on your script.

Groeten,
Marten :)

lasor
08-23-2004, 03:08 PM
Hi Marten

That works ok on my site, however when I send the email I get no errors but the email I receive does not include the added feild.

this is my altered contus.php

<?php
include("include/common.php");
include("$config[template_path]/user_top.html");
?>
<br>
<div align="center">
<table width="600" border="0">
<tr>
<td align="center">&nbsp;</td>
<td align="center"><i><b> <font color="#42557B" size="4">Contact Company Name</font></b></i><p> <font color="#42557B" size="2">You can contact
Company Name in
a number of ways.</font></td>
</tr>
<tr>
<td align="center"><font color="#42557B" size="2"><b><i>By Phone</i></b></font></td>
<td align="center"><font color="#42557B" size="2">(000) 000-000</font></td>
</tr>
<tr>
<td align="center"><font color="#42557B" size="2"><b><i>By Fax</i></b></font></td>
<td align="center"><font color="#42557B" size="2">(000) 000-0000</font></td>
</tr>
<tr>
<td align="center"><font color="#42557B" size="2"><b><i>By Mail</i></b></font></td>
<td align="center"><font size="2" color="#42557B">Coming Soon</font></td>
</tr>
<tr>
<td colspan="2" align="center"><font color="#42557B" size="2">We look forward to hearing
from you!</font><br>
</td>
</tr>
</table>
</div>
<br>
<div align="center">
<table border="2" width="300" id="table1" bordercolor="#42557B">
<tr>
<td>&nbsp;<html>
<head>
<title>Email Form </title>
</head>
<body>

<form method="POST" action="sendeail.php">

<input type=hidden name="httpagent" value="<?php echo $httpagenti ?>">


<input type=hidden name="httpref" value="<?php echo $httprefi ?>">

<input type=hidden name="ip" value="<?php echo $ipi ?>">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?><b><font color="#42557B">Your Name:</font></b> <input type=text name="visitor" size="35">
<br>
<b><font color="#42557B">Your Email:</font></b> <input type=text name="visitormail" size="35"><p>
<font color="#42557B"><SELECT NAME = "subject1" size="1">
<OPTION SELECT>Please Select A Subject</OPTION>
<OPTION>1. Comment</OPTION>
<OPTION>2. Question</OPTION>
<OPTION>3. Suggestion</OPTION>
<OPTION>4. Advertise</OPTION>
<OPTION>5. Accounts</OPTION>
<option>6. Support</option>
<option>7. General</option>
</SELECT></font>
<br><br>
<b><font color="#42557B">Mail Message:</font></b>
<br>
<textarea name=notes rows=4 cols=40></textarea>
<br>
<input type=submit VALUE="Send Mail">
<br>
&nbsp;</p>
</form>

</body>
</html></td>
</tr>
</table>
</div>
<p>
<br>

</p>


<?php
include("$config[template_path]/user_bottom.html");
?>

And this is the script it uses to send

<?php


include("include/common.php");


include("$config[template_path]/user_top.html");
?>
<html>
<head>
<title>Sendemail Script</title>
</head>
<body>

<!-- You must enter YOUR email address ($myemail shown below).
Then you should check (or modify) the link for the 'next page' (at the bottom) -->

<?php
$myemail = "test@mydomain.co.uk";

if (!isset($visitormail))
echo "Somebody Goofed $ip" ;

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Visitor Mail" ;

$message = " $todayis [EST] \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $myemail\r\n";

if ($myemail != "")
mail($myemail, $subject, $message, $from);

?>

<b><p align=center>
Date: <?php echo $todayis ?>
<br>
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br>
<?php echo $ip ?>

<br><br>
<a href="http://www.mydomain.co.uk/index.php">Home</a>

</body>
</html>

<?php
include("$config[template_path]/user_bottom.html");
?>

Is there anything you can see there that might be stopping this working. Just a note. in the line mail($myemail, $subject, $message, $from); I tried just adding the new field (I renamed it subject1 as there is also a subject field in the script. I also renamed it in the contactus.php) however this is what then stops the email working.
Also you will notice in the script that this script should also capture IP address and browser. but that does not seem to be working.

It would be nice to get this working so that it could be packaged up for others to use.

Lasor

marb
08-24-2004, 01:46 AM
That field is not working correct course it have no reference to go.

Example is the first part of the second script i place in me other post;


<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
var blank = "";
return blank;
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "mailto:antispammer@earthling.net?subject=TJS - Comment";
else if (Subject.selectedIndex == 2) action = "mailto:antispammer@earthling.net?subject=TJS - Question";
else if (Subject.selectedIndex == 3) action = "mailto:antispammer@earthling.net?subject=TJS - Suggestion";
else if (Subject.selectedIndex == 4) action = "mailto:antispammer@earthling.net?subject=TJS - Broken Link";
else action = "mailto:antispammer@earthling.net?subject=TJS - Other";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</SCRIPT>


Such a part of this is missing in the script you use;


function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "mailto:antispammer@earthling.net?subject=TJS - Comment";
else if (Subject.selectedIndex == 2) action = "mailto:antispammer@earthling.net?subject=TJS - Question";
else if (Subject.selectedIndex == 3) action = "mailto:antispammer@earthling.net?subject=TJS - Suggestion";
else if (Subject.selectedIndex == 4) action = "mailto:antispammer@earthling.net?subject=TJS - Broken Link";
else action = "mailto:antispammer@earthling.net?subject=TJS - Other";
}


You can ad this part in the script you use.
Let me know of it work.
Think the first script I place here is complete and easy to install also to integrate in OR, perhaps a bit tweake.



Groeten,
Marten :)

lasor
08-24-2004, 03:23 AM
Hi Marten

Thanks for your time on this, I appreciate your input

The reason I am not using the above script is because I am trying to set up a secure contact us form that does not use things like mailto: My reason is to aviod email harvestors, something that I have suffered from in the past. The script I am using at the moment works fine. It just needs that little tweak to get an option list feild working.

Lasor

flyboydea
09-06-2004, 11:25 PM
I am using VDaemon and it seems to work very well for PHP forms. Their Secure Version is only $12., and not to hard to use once you read the documentation.

http://www.x-code.com/vdaemon_secure.php

- Flyboydea