Jump to content


Photo

contact form help


  • Please log in to reply
7 replies to this topic

#1 SERB-4-LIFE

SERB-4-LIFE

    Young Padawan

  • Members
  • Pip
  • 65 posts

Posted 08 October 2004 - 03:10 AM

ok i got this as a tutorial on one forum now it doesnt work it a fancy contact form here is the code
<?
//////////////////////////////
//
// copyright 2004 by Dude
// www.phpground.net
// version 1.6.4
// License: freeware ~ all I ask is you put a link to www.phpground.net
// somewhere on your site, thanks
//
//////////////////////////////
///////[ BASIC CONFIGURATION - edit below
//////////////////////////////

$to = "[email protected]";         // your email address
$commentlimit = "400";            // comments limit
$subject = "Contact From Site";   // the email subject you get
$formaction = "main.php?page=contact"; // form action
//below is your contact message explanation - be carefull when using html
$contact_explain = "From here you can contact us, just remember not to <a title=\"Flooding the Internet with many copies of the same message\">spam</a> as all <a title=\"unique identifying number\">IP addresses</a> are logged.";
//fancy inputs - yes/no
$fancy_inputs = "yes";
//skip two below if fancy inputs is set to no
$mouseover_input = "#E0E6EA";    // the color when you put your mouse over a input
$mouseout_input = "#EFEFEF";    // the color when your mouse gos off an input
//customize input information - yes/no
$show_website = "yes";
$show_company = "yes";
$show_position = "yes";
$show_postal_address = "yes";
$show_zip_code = "yes";
$show_country = "yes";
$show_telephone = "yes";
$show_fax = "yes";
//
$use_javascript = "yes"; // we recommend you leave this to yes

//////////////////////////////
///////[ DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOUR DOING
/////////////////////////////
if ( isset($_REQUEST['action']) )
{
$action = $_REQUEST['action'];
}
if($fancy_inputs == "yes"){
$be_fancy = " onmouseover=\"this.focus(); this.style.backgroundColor='$mouseover_input';\" onmouseout=\"this.style.backgroundColor='$mouseout_input';\"";
$be_fancy2 = " onmouseover=\"this.style.backgroundColor='$mouseover_input';\" onmouseout=\"this.style.backgroundColor='$mouseout_input';\"";
}
else
{
$be_fancy = "";
$be_fancy2 = "";
}
$sitehome = $_SERVER['HTTP_HOST'];
$name = @trim($_POST['name']);
//$sitehome = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
$email = @trim($_POST['email']);
//$url = @trim($_POST['url']);

$url = $_POST['url'];

$company = @trim($_POST['company']);
$position = @trim($_POST['position']);
$postal_address = @trim($_POST['postal_address']);
$zip_code = @trim($_POST['zip_code']);
$country = @trim($_POST['country']);
$telephone = @trim($_POST['telephone']);
$fax = @trim($_POST['fax']);
$comments = @trim($_POST['comments']);
$subject1 = @trim($_POST['subject1']);
$priority = @trim($_POST['priority']);
$ip = $_SERVER['REMOTE_ADDR'];
$iphost = $_SERVER['REMOTE_HOST'];
$User_Agent = $_SERVER['HTTP_USER_AGENT'];
$User_Refer = $_SERVER['HTTP_REFERER'];
$host = $_SERVER['HTTP_HOST'];
$messageid = md5(uniqid(rand(),1));
$messageid = substr(md5(time()),0,10);
// to add more stuff just use    bleh: $bleh\n

///////the cleaning begins; useless? maybe
$name = ereg_replace("[ ]{2,}", " ", $name);
$name = str_replace("\"", "&quot;", $name);
$name = str_replace("\n", " &lt;br /&gt;", $name);
$name = str_replace("\$", " $", $name);
$name = strip_tags($name, '');
//
$email = preg_replace('/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?))/i', "<a href='mailto:\\1'>\\1</a>", $email);
$email = ereg_replace("[ ]{2,}", " ", $email);
$email = strip_tags($email, '');
//
$country = ereg_replace("[ ]{2,}", " ", $country);
$country = strip_tags($country, '');
//
$comments = ereg_replace("[ ]{2,}", " ", $comments);
$comments = str_replace("\"", "&quot;", $comments);
$comments = str_replace("\n", " <br />", $comments);
$comments = str_replace("\$", " $", $comments);
$comments = strip_tags($comments, '');
// - some people view source :/
$ip = ereg_replace("[ ]{2,}", " ", $ip);
$ip = strip_tags($ip, '');
//
$User_Agent = ereg_replace("[ ]{2,}", " ", $User_Agent);
$User_Agent = strip_tags($User_Agent, '');
// - well we only want a url to be proccesed, right?
$User_Refer = preg_replace('/(http|ftp|news|https)(:\/\/)([^<> ])+/i', "<a href='\\0>\\0</a>", $User_Refer);
$User_Refer = ereg_replace("[ ]{2,}", " ", $User_Refer);
$User_Refer = strip_tags($User_Refer, '');
// finshed cleaning?
$to_day = date("F j, Y, g:i a");
$os_search = array("aix", "atheos", "amiga", "beos", "Darwin", "freebsd", "irix", "linux", "Mac_PowerPC", "netbsd", "os2", "openbsd", "OpenVMS", "photon", "unixware", "Windows 2003", "Windows NT 5\.2", "Windows 2000", "Windows NT 5\.0", "windows 95", "win95", "Windows CE", "windows me", "winme", "win 9x 4\.90", "windows-nt", "winnt", "Windows XP", "Windows NT 5\.1", "bsd", "mac", "windows 98", "win98", "wi(n|n32|ndows)", "Windows 2000", "Windows 98", "Windows 95", "Win95", "Win98", "Windows NT 4.0", "Windows NT 5.0", "Windows NT 5.1", "Windows XP", "Windows ME", "WinNT", "Mac_PowerPC", "Macintosh", "SunOS", "Linux", "Windows NT");
$os = array("AIX", "AtheOS","Amiga", "BeOS", "Darwin", "FreeBSD", "IRIX", "Linux", "MacOS PPC", "NetBSD", "OS2", "OpenBSD", "OpenVMS", "QNX Photon", "UnixWare", "Windows 2003", "Windows 2003", "Windows 2000", "Windows 2000", "Windows 95", "Windows 95", "Windows CE", "Windows ME", "Windows ME", "Windows ME", "Windows NT", "Windows NT", "Windows XP", "Windows XP", "BSD", "MacOS", "Windows 98", "Windows 98", "Windows", "Windows 2000", "Windows 98", "Windows 95", "Windows 95", "Windows 98", "Windows NT 4.0", "Windows NT 5.0", "Windows XP", "Windows XP", "Windows ME", "Windows NT", "Macintosh", "Macintosh", "SunOS", "Linux", "Windows NT");
$browser_search = array("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera ","abrowse", "aol browser", "beonex", "dillo", "galeon", "ibrowse", "java", "libwww-perl", "libwww-FM", "libwww", "mosaic", "nautilus", "safari", "webtv", "compatible; MSIE 6.0; Windows NT 5.1; MSN 6.1; MSNbMSFT; MSNmnl-nl; MSNc00; v5m", "MSIE 6.0", "MSIE 5.5", "MSIE 5.0", "MSIE 4.0","Opera","Konqueror","Mozilla/5", "Mozilla/4", "Mozilla");
$browser = array("Opera Browser","ABrowse", "AOL", "Beonex", "Dillo", "Galeon", "IBrowse", "Java", "libWWW", "libWWW", "libWWW", "Mosaic", "Nautilus", "Safari", "Webtv", "MSN Explorer", "Internet Explorer 6","Internet Explorer 5.5", "Internet Explorer 5", "Internet Explorer 4", "Opera","Konqueror","Netscape 6.x", "Netscape 4.x", "Netscape");
$other = 1;
while(list($key, $value) = each ($os_search)) {
$pos = strpos ($HTTP_USER_AGENT, $value);
if($pos !== false){
$opsys = $os[$key];
$other = 0;
break 1;
}
}
if($other != 0){ $opsys = "Other"; }
$other = 1;
while(list($key, $value) = each ($browser_search)) {
$pos = strpos ($HTTP_USER_AGENT, $value);
if($pos !== false){
$ibrowser = $browser[$key];
$other = 0;
break 1;
}
}
if($other != "0"){ $ibrowser = "Other"; }
$error_br = "<br /><br /><br /><br /><br /><br />";
$error_br2 = "<br /><br /><br /><br /><br /><br /><br />";

$body = "Hello $to,\nsomeone has contacted you from your site on $to_day\nthe message details are as follows:\n\n\n Name: $name\n Email: $email\n Url: $url\n Company: $company\n Position: $position\n Postal Address: $postal_address\n Zip Code: $zip_code\n Country: $country\n Telephone: $telephone\n Fax: $fax\n Subject: $subject1\n Priority Level: $priority\n Comments: $comments\n\n--------------------\n: : : User information\n IP Address: $ip - http://network-tools.com/default.asp?host=$ip\n$iphost\n System: $opsys\n Browser: $ibrowser\n User Agent: $User_Agent\n User Refer: $User_Refer\n Site Host: $host\n Message ID: $messageid";
if ( $action == 'send' )
{
if(!ereg('.@.{5}', $email)){
echo <<<EOT
<center>$error_br<font color="FF0000"><b>Error: Not Completed</b></font><hr width="75%" />Please use your <a href="javascript:history.back(-1)">back</a> button and use a <u>real</u> email address, then resubmit.<br />
$error_br2</center>
EOT;
//include_once("your page footer");
exit;
}
if (($email=="") || ($subject1=="") || ($name=="") || ($ip=="")  || ($email=="")|| ($comments==""))  { 
echo <<<EOT
<center>$error_br<font color="FF0000"><b>Error: Not Completed</b></font><hr width="75%" />Please use your <a href="javascript:history.back(-1)">back</a> button and complete <u>all</u> of the required form fields, then resubmit.<br />
$error_br2</center>
EOT;
//include_once("your page footer");
exit;
} else {
mail("$to",$subject,$body,"From: contact@$sitehome");
echo <<<EOT
<center><br />
<br />
<br />
<br />The contact request has been sent,<br />
with the messages as:<br />
Subject: $subject1<br />
$comments<br />
from $email<hr width="75%" /><br />
<br />Please allow 24-48 hours for a response<br />
<br />
<br /><hr width="75%" />your message id is $messageid<br />
which you may keep if needed to contact us again on the same subject for reference.<br />
<br /><br /><br /></center>
EOT;
//include_once("your page footer");
exit;
}
}
echo <<<EOT
<big>Contact</big>
<hr />
$contact_explain<br /><br /><br /><br />
<small><i>&nbsp; Items marked with a <font color="FF0000">*</font> are required</i></small><br /><br />
EOT;
if($use_javascript == "yes"){
echo <<<EOT
<script language="Javascript" type="text/javascript">
function TrackCount(fieldObj,countFieldName,maxChars)
{
var countField = eval("fieldObj.form."+countFieldName);
var diff = maxChars - fieldObj.value.length;
// Need to check and enforce limit here also in case user pastes data
if (diff < 0)
{
fieldObj.value = fieldObj.value.substring(0,maxChars);
diff = maxChars - fieldObj.value.length;
}
countField.value = diff;
}
function LimitText(fieldObj,maxChars)
{
var result = true;
if (fieldObj.value.length >= maxChars)
result = false;
if (window.event)
window.event.returnValue = result;
return result;
}
function onlyNumber(){
if((event.keyCode<48)||(event.keyCode>57)){ 
if((event.keyCode==46)||(event.keyCode==45)||(event.keyCode==44)){}
else{event.returnValue=false;}
}
}
var submitted = false;
function submitCheck() {
if (submitted) {
alert("You have already pressed the submit button. Please wait...");
return false;
} else {
submitted = true;
return true;
}
}
</script>
<noscript><center>Please enable javascript</center></noscript>
EOT;
$javascript_key1 = " onkeypress=\"javascript:onlyNumber();\"";
$textbox_javascrpt = " onkeyup=\"TrackCount(this,'textcount',$commentlimit)\" onkeypress=\"LimitText(this,$commentlimit)\" title=\"Required Information\"></textarea> <input type=\"text\" name=\"textcount\" size=\"3\" value=\"$commentlimit\" readonly=\"readonly\" /> <small>letters left</small>";
}
if($use_javascript == "no"){
$javascript_key1 = "";
$textbox_javascrpt = " title=\"Required Information\"></textarea>";
}
if($use_javascript == "yes"){
echo "<form action=\"$formaction&amp;action=send\" method=\"post\" onsubmit=\"return submitCheck()\">";
}
if($use_javascript == "no"){
echo "<form action=\"$formaction&amp;action=send\" method=\"post\">";
}
echo <<<EOT
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td width="90" align="right"><a title="Required Information"><font color="FF0000">*</font></a>Name:</td>
<td><input type="text" name="name" size="15" maxlength="20"$be_fancy title="Required Information" /></td>
</tr>
<tr>
<td width="90" align="right"><a title="Required Information"><font color="FF0000">*</font></a>Email:</td>
<td><input type="text" name="email" size="25" maxlength="35"$be_fancy title="Required Information" /></td>
</tr>
EOT;
if($show_website == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Web Site:</td>
<td><input type="text" name="url" size="25" value="http://"$be_fancy /></td>
</tr>
EOT;
}
if($show_company == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Company:</td>
<td><input type="text" name="company" size="25" value=""$be_fancy /></td>
</tr>
EOT;
}
if($show_position == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Position:</td>
<td><input type="text" name="position" size="25" maxlength="20" value=""$be_fancy /></td>
</tr>
EOT;
}
if($show_postal_address == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Postal Address:</td>
<td><input type="text" name="postal_address" size="25" maxlength="35" value=""$be_fancy /></td>
</tr>
EOT;
}
if($show_zip_code == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Zip Code:</td>
<td><input type="text" name="zip_code" size="25" maxlength="20" value=""$javascript_key1$be_fancy /></td>
</tr>
EOT;
}
if($show_country == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Country:</td>
<td><input type="text" name="country" size="25" value=""$be_fancy /></td>
</tr>
EOT;
}
if($show_telephone == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Telephone:</td>
<td><input type="text" name="telephone" size="25" maxlength="20" value=""$javascript_key1$be_fancy /></td>
</tr>
EOT;
}
if($show_fax == "yes"){
echo <<<EOT
<tr>
<td width="90" align="right">Fax:</td>
<td><input type="text" name="fax" size="25" maxlength="20" value=""$javascript_key1$be_fancy /></td>
</tr>
EOT;
}
echo <<<EOT
<tr>
<td width="90" align="right"><a title="Required Information"><font color="FF0000">*</font></a>Subject:</td>
<td><input type="text" name="subject1" size="25" maxlength="35" value=""$be_fancy title="Required Information" /></td>
</tr>
<tr>
<td width="90" align="right"><a title="Required Information"><font color="FF0000">*</font></a>Priority:</td>
<td><select name="priority"$be_fancy2 title="Required Information"><option value="1" selected="selected">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
<option value="4">Urgent</option>
</select></td>
</tr>
<tr>
<td width="69" align="right" valign="top"><a title="Required Information"><font color="FF0000">*</font></a>Comments:<br />
Max: $commentlimit</td>
<td>
<textarea name="comments" class="post" rows="9" cols="40"$be_fancy$textbox_javascrpt</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value=" Submit "$be_fancy2 /> &nbsp; <input type="reset" value="Reset" name="reset"$be_fancy2 /></td>
</tr>
</table>
</form><br /><br />
EOT;
?>

its huge :hi: if someone can see the problem please help

#2 z77

z77

    Content Contributor

  • Members
  • Pip
  • 176 posts
  • Location:Atlanta
  • Interests:Art, Computers, Goldfish, Church, Pizza, Ice Cream, Frisbee, Paintball, PHP, C4D, Photoshop, Friends :)

Posted 08 October 2004 - 04:48 AM

can you give us the error?

#3 SERB-4-LIFE

SERB-4-LIFE

    Young Padawan

  • Members
  • Pip
  • 65 posts

Posted 08 October 2004 - 05:24 AM

there is no errors, when i click on the send button to send the email it sends me to the first page of my site and i never receive the email

#4 Jamie Huskisson

Jamie Huskisson

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 3,648 posts
  • Gender:Male
  • Location:Nottingham, UK

Posted 08 October 2004 - 10:11 AM

//////////////////////////////
///////[ DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOUR DOING
/////////////////////////////

read the script first

and btw - not a v.good script at that

#5 Unreal

Unreal

    like.. TOTally cool!

  • Members
  • Pip
  • 241 posts

Posted 08 October 2004 - 11:32 AM

what the hell? if thats just a simple emailing script form thing then it needs to be nowhere near that size!

#6 SERB-4-LIFE

SERB-4-LIFE

    Young Padawan

  • Members
  • Pip
  • 65 posts

Posted 08 October 2004 - 07:45 PM

//////////////////////////////
///////[ DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOUR DOING
/////////////////////////////

read the script first

and btw - not a v.good script at that

man i know what i am doing :huh: i tried the original code as well but it did the same thing

#7 shao

shao

    Original P2L Programmer

  • Members
  • Pip
  • 49 posts
  • Gender:Male
  • Location:Canada

Posted 08 October 2004 - 08:53 PM

Could be the "mail" function is filtered on your site or port 25 is disabled. Check with your host to see what gives. Have you tried a simple php script with the mail function? And make sure you form it properly, as most people have so much trouble that they forget a letter or something, a real pain. Good luck, eh!

#8 SERB-4-LIFE

SERB-4-LIFE

    Young Padawan

  • Members
  • Pip
  • 65 posts

Posted 09 October 2004 - 01:58 AM

yeh i had mail forms before with the mail function ok let me explain more.

wel u see this code l
$to = "[email protected]";         // your email address
$commentlimit = "400";            // comments limit
$subject = "Contact From Site";   // the email subject you get
$formaction = "main.php?page=contact"; // form action
//

$formaction was index.php?page=contact
and i putted main.php because my main page is called main.php if it stayed on index.php it would say the page not found
thats why i putted main.php

and when i click on serb it shows like the adres mysite.com/main.php?page=contact?action=send something like that
but it doesnt send

hope this clears some things up so u can help me




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users