Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-07-2005, 11:19 AM
alwaysme
Unregistered

Posts: n/a

Help with the form please!

the form only sends an email to one address. I'd like to add a drop down menu to the form so that the sender can choose whom to email.

can anyone please help! ?


here is most of the code of the script

[code:1:2f5ae9384d]<?php

/*
//================================================== ==============================
* phphq.Net Custom PHP Scripts *
//================================================== ==============================
:- Script Name: phMailer
:- Version: 1.3
:- Release Date: Jan 27th 2004
:- Release Date: July 21st 2004
:- Author: Scott L. aka. Panther <scott@phphq.net> http://www.phphq.net
:- Copyright (c) 2004 All Rights Reserved
:-
:- This script is freeware. Permission is granted to copy and distribute this
:- program so long as it is not modified in any way and no fees are exchanged.
:- All copyright text must remain visible and unmodified.
//================================================== ==============================
* Description
//================================================== ==============================
:- phMailer is a php mail script. It can be used on your site as a contact form. This is very helpful if you want your visitors to be
:- able to contact you without them knowing your real email address. On great feature of this script is the ability to allow users
:- to attach files when sending an email directly from your site. Of course, you can disable this feature if you wish.
:- Currently, only zip files are supported for sending attachments in this SimpleMailer script. I would add more, but zip files in
:- email are basically harmless unless they are extracted and opened, this gives you at least a chance to defend yourself from
:- a possibly serious infection. Another popular use for an email form is protection against spam bots. Spam, is a major downside
:- of email, and placing your email publicly on your website is asking for spam. Spam bots can take your email address right off
:- your site and add it to thousands of spam databases. Resulting in a never ending supply of spam for you. I coded this script,
:- because I couldn't find a simple mailer that would allow my visitors to send attachments.
//================================================== ==============================
* Setup
//================================================== ==============================
:- To setup this script, simply drop this file anywhere in your website. Then edit the vars in phMailer.php.
//================================================== ==============================
* Frequently Asked Questions
//================================================== ==============================
:- Q1: I never recieved any mail, but people say they have emailed me.
:- A1: Try the mailtest.php file that came with this script. If that fails, then mail() is not setup right. Please contact your host
:- A2: Did you change anything within the file? Are you sure your email is correct?

:- Q2: I never recieve any attachments.
:- A1: Maybe your server has some security against uploading files or sending attachments through mail.
:- A2: Maybe the files people are submitting are to big. Check php.ini for the max_post_size and max_upload_size.
:- A3: Maybe your server wont sent files bigger then the files they are trying to submit.
*/


/*
//================================================== ==============================
* ! ATTENTION !
//================================================== ==============================
:- Please read the above FAQ before giving up or emailing me. It may sort out your problems!
*/


//Allowed file types. Please remember to keep the format of this array, add the file extensions you want without the dot. Please also be aware that certain file types may cause harm to your website and or server.
$allowtypes=array("jpg", "jpeg", "bmp", "gif", "3gp");
$myemail="test@test.com"; // What's your email address?
$priority="3"; // What priority should I send the mail? 1 is Urgent, 10 Is low. 3 Is default.
$allowattach="1"; // Should we allow visitors to attach *.zip files? 1=yes, 0=no.


$submitvalue=" Send Request "; // Value for the Submit Button
$resetvalue=" Reset Form "; // Value for the Reset Button
$defaultsubject="Request Form"; // Default subject header? This will be sent if the user does not specify a subject.
$thanksmessage="Thank you! Your request has been sent, we will respond shortly and let you know if your car is q8speed worthy (make sure you have atleast 3 good quality pictures ready)."; //Your thank you message, displays after the email has been sent.


$twidth="450"; // Table Width
$tableborder="0"; // Show table border? 1=yes, 0=no.
$tbordercolor="#4f4f4f"; // Table Border Color
$thead="#4f4f4f"; // Table head background Color
$tbody="#898483"; // Table Body Background Color

$bgcolor="#4f4f4f"; // Page bg Color

$fontface="Verdana,Arial"; // Font face
$fonthead="#ffffff"; // Font Head Color
$fontheadsize="10"; // Font Head Size
$fontbody="#cccccc"; // Font BodyColor
$fontbodysize="10"; // Font Body Size

/*
//================================================== ==============================
* Attention
//================================================== ==============================
: Don't edit below this line unless you know some php. Editing some variables or other stuff could cause undeseriable results!!
*/

function get_ext($key) {
return(strtolower(substr(strrchr($key, "."), 1)));

}

If($_POST['domail']) {

extract($_POST, EXTR_SKIP);

If($allowattach) {
$attachment=$_FILES['attachment']['tmp_name'];
$attachment_type=$_FILES['attachment']['type'];
}

If ($yourname=="") {
$error = "1";
$error_text .= "You did not enter your name!<br />";
}

If ($youremail=="") {
$error = "1";
$error_text .= "You did not enter your email!<br />";
}

If($emailsubject=="") {
$emailsubject=$defaultsubject;
}

If ($youremail) {
If (!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)){
$error = "1";
$error_text .= "Invalid Email Address!<br />";
}
}

If ($yourmessage=="") {
$error = "1";
$error_text .= "You did not enter a message!<br />";
}

If ($location=="") {
$error = "1";
$error_text .= "You did not enter the name of your car<br />";
}

If($allowattach) {

foreach($allowtypes as $it) {
$types .="*.".$it.",";
}

If($attachment) {
$ext=get_ext($_FILES[attachment][name]);
If(!in_array($ext, $allowtypes)) {
$error = "1";
$error_text .= "Invalid extension for your attchment, only ".$types." are allowed!<br />";
}
}
}

If($error=="1") {

$disperrors=$error_text;

} Else {

$headers = "From: ".$yourname." <".$youremail.">\n";
$headers .= "Reply-To: ".$yourname." <".$youremail.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\n";
$headers .= "X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers .= "X-Priority: ".$priority."\n";
$headers .= "Return-Path: <".$myemail.">\n";
$headers .= "This is a multi-part message in MIME format.\n";

If($allowattach) {
If($attachment) {
$fp=@fopen($attachment,"r");
$str=@fread($fp, filesize($attachment));
$str=@chunk_split(base64_encode($str));
}
}

$message = "--MIME_BOUNDRY\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";

$message .= "\n";
$message .= "$carmake";
$message .= "\n";
$message .= "$year";
$message .= "\n";
$message .= "$location";
$message .= "\n";
$message .= "$yourmessage";
$message .= "\n";
$message .= "$was6a";
$message .= "\n";
$message .= "$showemail";
$message .= "\n";

If($allowattach) {
If($attachment) {
$message .= "--MIME_BOUNDRY\n";
$message .= "Content-Type: application/octet-stream; name=\"" . $_FILES['attachment']['name'] . "\"\n";
$message .= "Content-disposition: attachment\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "\n";
$message .= "$str\n";
$message .= "\n";
$message .= "--MIME_BOUNDRY--\n";
}
}

If(!mail($myemail,$emailsubject,$message,$headers) ) {
exit("There has been an error, please contact the admin");
}

Echo("<center><font face=\"verdana\" size=\"1\" color=\"#ffffff\">".$thanksmessa ge."</div>");

}

}


/*
//================================================== ==============================
* Start the form layout
//================================================== ==============================
:- Start the form, if you are editing this form, please remember to escape all quotes " with a backslash, an example would be <input type=\"text\">
:- If you do not do this, you will get phrase errors.
:- Also, please remember that if you change values in this form, the script may not work how it was originally meant to.
*/


Echo("<html>\n");
Echo("<head>\n");
Echo("<title>".$websitename." - contact</title>\n");
Echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n");
Echo("<style type=\"text/css\">\n");
Echo("a:link {text-decoration:none; color:".$fontbody.";}\n");
Echo("a:visited {text-decoration:none; color:".$fontbody.";}\n");
Echo(".head{font-family:".$fontface."; font-size:".$fontheadsize."; color:".$fonthead."; font-weight:bold;}\n");
Echo(".body{font-family:".$fontface."; font-size:".$fontbodysize."; color:".$fontbody.";}\n");
Echo("input { font-family:".$fontface."; font-size:".$fontbodysize."px; color:".$fonthead."; border:1px solid ".$tbordercolor."; background-color:".$thead.";}\n");
Echo("</style>\n");
Echo("</head>\n");
Echo("<body>\n");
Echo("<div align=\"center\" class=\"body\"><b>".$dispe rrors."</b></div>");
Echo("<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\& quot;"); If($allowattach){Echo(" enctype=\"multipart/form-data\"");}Echo(">\n");
Echo("<table cellspacing=\"0\" cellpadding=\"1\" border=\"".$tborder."\" style=\"border-collapse: collapse\" bordercolor=\"".$tbordercolor."\&qu ot; align=\"center\" width=\"".$twidth."\" bgcolor=\"".$tbody."\" class=\"body\">\n");
Echo("<tr>\n");
Echo("</tr>\n");
Echo("<td width=\"40%\" > Name</td>\n");
Echo("<td width=\"60%\"><input name=\"yourname\" type=\"text\" size=\"30\" value=\"".stripslashes($yourname)." \" /></td>\n");
Echo("</tr>\n");
Echo("<tr>\n");
Echo("<td width=\"40%\">Your Email:</td>\n");
Echo("<td width=\"60%\"><input name=\"youremail\" type=\"text\" size=\"30\" value=\"".stripslashes($youremail).&quot ;\" /></td>\n");
Echo("</tr>\n");
Echo("<tr>\n");
If($allowattach) {
Echo("<tr>\n");
Echo("<td width=\"30%\">Attachment:</td>\n");
Echo("<td width=\"70%\"><input name=\"attachment\" type=\"file\" size=\"30\" /></td>\n");
Echo("</tr>\n");
}

Echo("<tr>\n");
Echo("<tr>\n");
Echo("<tr bgcolor=\"".$thead."\">\n&q uot;);
Echo("<td colspan=\"2\" align=\"center\"><input name=\"domail\" type=\"submit\" value=\"".$submitvalue."\" /> <input type=\"reset\" value=\"".$resetvalue."\" /></td>\n");
Echo("</tr>\n");
Echo("</table>\n");
Echo("</body>\n");
Echo("</html>\n");
?>[/code:1:2f5ae9384d]

i want the list to be on top of the field name.......please may someone help me ?
Reply With Quote
  #2  
Old 12-10-2005, 10:55 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

This has been added in phMailer 1.5. Thanks for the 'suggestion'
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
form mail Acid Web design and Programming 5 02-08-2009 07:24 PM
problem with contact form navysea| Web design and Programming 4 01-23-2006 07:40 PM
CSS and PHP Form Help! Webviper2006 Web design and Programming 3 12-30-2005 04:49 PM
Resetting the Form? Mark phphq.Net Forums 1 01-27-2005 12:54 AM
form help SilentRanger Web design and Programming 6 09-12-2004 02:13 PM


All times are GMT -5. The time now is 09:05 AM.




Powered by vBulletin®