PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 13th, 2004, 02:19 AM
lindatasha lindatasha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 lindatasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question php mail form modification

Hi!

I need your help, guys!

I have this PHP mail form that I want to use on my website, but I want to add additional fields to it.
How can I do this? I need to add fields like: your occupation? your profession? your education? your interests? etc...

PLEASE, HELP!

Here is a code:


<?php
error_reporting(0);
define("TO", "Linda <myemail@mywebsite.com>");
include("design.php");
$error_flag = false;
if (sizeof($HTTP_POST_VARS) >= 4) {
$sender_name = $HTTP_POST_VARS['sender_name'];
$sender_mail = $HTTP_POST_VARS['sender_mail'];
$mail_subject = $HTTP_POST_VARS['mail_subject'];
$mail_body = $HTTP_POST_VARS['mail_body'];
if (strlen($sender_name) < 3 || strlen($sender_name) > 40) {
$error_flag = true;
$error_message = "<p class=\"error\"><b><font color=#FC0433>Please, type your name correctly!</font></b></p>";
}
elseif (!eregi("^.+@(.+\.)+.+$", $sender_mail) || strlen($sender_mail) < 8 || strlen($sender_mail) > 40) {
$error_flag = true;
$error_message = "<p class=\"error\"><b><font color=#FC0433>Please, type your e-mail correctly!</font></b></p>";
}
elseif (strlen($mail_subject) < 4) {
$error_flag = true;
$error_message = "<p class=\"error\"><b><font color=#FC0433>What's your subject?</font></b></p>";
}
elseif (strlen($mail_body) < 4) {
$error_flag = true;
$error_message = "<p class=\"error\"><b><font color=#FC0433>What's your message?</font><b></p>";
}
$mail_headers = "Return-Path: ".reserve."\n".
"From: ".$sender_name."<".$sender_mail.">\n".
"Reply-To: ".$sender_name."<".$sender_mail.">\n".
"Content-Type: text/plain; charset=windows-1251\n".
"Content-Transfer-Encoding: 8bit\n".
"Date: " . date("r")."\n".
"X-Mailer: mailer_".$SERVER_NAME;
}
head();

if (empty($sender_name) || $error_flag) : print_mail_form();
elseif (mail(TO, $mail_subject, $mail_body, $mail_headers)) :
?>
<table width="70%" border="0" cellspacing="0" cellpadding="8" class="mail_sended">
<td align=center><b>Your information has been received.<br>Thanks for your interest.</b></td>
</table>
<?php else :
echo ("<p><b>Your message has not been sent.<br>Please, try again or try next time.</b></p>");
$error_message = "";
$error_flag = true;
print_mail_form();
endif;
foot();
function print_mail_form() {
global $error_flag, $error_message, $sender_name, $sender_mail, $mail_subject, $mail_body;
if (empty($sender_name)) $sender_name = "";
if (empty($sender_mail)) $sender_mail = "";
if (empty($mail_subject)) $mail_subject = "";
if (empty($mail_body)) $mail_body = "";
?>
<?php if ($error_flag) echo $error_message;?>
<form method="post" name="mail" id="mail">

<p align=center><b>Please, fill in this form:</p>
<br>
<table border="0" cellspacing="0" cellpadding="1">
<tbody>
<tr><td><b>Full name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><input type="text" name="sender_name" id="sender_name" value="<? echo htmlspecialchars($sender_name);?>" size="32" maxlength="60"></td></tr>
<tr><td><b>E-mail address:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><input type="text" name="sender_mail" id="sender_mail" value="<? echo htmlspecialchars($sender_mail);?>" size="32" maxlength="60"></td>
</tr>
<tr><td><b>Subject:&nbsp;&nbsp; <b><input type="text" name="mail_subject" id="mail_subject" value="<? echo htmlspecialchars($mail_subject);?>" size="12"></td></tr>
<tr><td><b>Message:&nbsp;&nbsp;&nbsp;&nbsp;</b><textarea cols="27" rows="2" name="mail_body" id="mail_body" id="mail_body"><? echo htmlspecialchars($mail_body);?>
</textarea></td></tr>
<tr><td align=right><input type="submit" value="Send"></td></tr>
</tbody>
</table>
</form>
<?php }?>

</p>
</td></tr></table>



This form works perfectly! I just need to add more questions (fields) to it and I want them to come in the body of the e-mail with the name of that field and the answer of the user - so it could be convenient to read.

I would also need to add uploading a photo function in this form, but I guess that would be toooooo complicated.

Thanks in advance for your help!

Sincerely,
Linda

Reply With Quote
  #2  
Old April 13th, 2004, 02:21 AM
lindatasha lindatasha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 lindatasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I really need your help! Please, if you know how to do this, help me! Thank you!

Yours,

Linda

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > php mail form modification


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT