SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 47 of 47
  1. #26
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RocketMan
    1. To yield an error message if someone does NOT select the To: or Subj: options (i.e., make it a "Select One" arrangement). Some people need to be 'guided' in online forms
    Shouldn't be to hard.
    Quote Originally Posted by RocketMan
    2. I dunno if this is possible, but instead of re-directing to a main website domain, is there a way to have the redirect go back to the page from wherever the person clicked on the email 'form' ???

    3. If a person has an e-mail link to the form on every page in their website, it would be very cool to include (in the sent email) the actual page from where someone clicked on the e-mail form!!!
    Just add the current page name (as a query string) in the mail link on the page that the user is coming from. Then in the mail form page you just access this variable using the $_GET array.

    I'll come back with a code suggestion to the first of your items.

    -Helge

  2. #27
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.
    About you first suggestion. Change these lines in the script. It's important that you don't change the first element in the $sendto and $subjects arrays.
    PHP Code:
    $sendto = array('Select one'      => '',
                    
    'George Bush'     => 'bush@us.com'
                    
    'Bill Clinton'    => 'clinton@us.com'
                    
    'Ronald Reagan'   => 'reagan@us.com' 
                   
    ); 

    //***************

    $subjects = array(=> 'Select one',
                      
    => 'Help'
                      
    => 'Feedback'
                      
    => 'Tip' 
                     
    ); 

    // **************

    if(empty($to) || empty($sendto[$to])) $errorMsg[] = 'To';
    if(empty(
    $subject) || $subject == 0$errorMsg[] = 'Subject'
    I think that should work

    I hope we don't have "hijacked" btvillarin thread.

    -Helge

  3. #28
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Helge:

    I got another idea but would like to know how to extract ONLY (example) 'George Bush' ... the name only from the array:
    PHP Code:
    $sendto = array('Select one' => ''
    'George Bush' => [email='bush@us.com']'bush@us.com'[/email], 
    'Bill Clinton' => [email='clinton@us.com']'clinton@us.com'[/email], 
    'Ronald Reagan' => [email='reagan@us.com']'reagan@us.com'[/email
    ); 
    ...and assign it to a $var which can be included in the Subject Line.

    THANKS!!!

    (EDIT
    I tried this:
    PHP Code:
    list($toname,$notneeded) = $sendto;
    echo 
    $toname;
    exit; 
    ...but it doesn't work.
    Last edited by RocketMan; Oct 22, 2003 at 11:50.

  4. #29
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do you want the email adresses to be enclosed by those [email ] tags?
    Isn't it better to add those in the code where you set the subject variable? Or am I missing something here?

    -Helge

  5. #30
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Last post I used was #18 in this thread. It's cool that it got quite a few more, though. Rocketman, it's totally fine.

    Email validation would really be great! The way the script is, if you put some text in the email box, anything works...even if it's not an email address!

    Also, I was wondering if the script can be modified because single quotation marks are preceded with a slash. /

    AND, is there any way I can just have the subject to be shown in the actual headers of the email, rather than in the body of the email?

    Thanks! I think this thread is totally cool...so much help and everything.
    Bryan T. Villarin
    All Narfed Up My System Rig

  6. #31
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.
    Quote Originally Posted by btvillarin
    Email validation would really be great!
    To do a simple email validation add this code to where the other fields get checked.
    PHP Code:
    $searchstring "^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$^";
    if(
    preg_match($searchstring$senderemail)) $errorMsg[] = 'Your E-mail address is not in a valid format'
    Quote Originally Posted by btvillarin
    Also, I was wondering if the script can be modified because single quotation marks are preceded with a slash. /
    This is because of a setting/feature called magic_quotes_gpc. To get more info and a solution see the magic_quotes, addslashes(), and stripslashes() part of PHP and MySQL coding tips (post nr.1) started by DR_LaRRY_PEpPeR.
    Quote Originally Posted by btvillarin
    AND, is there any way I can just have the subject to be shown in the actual headers of the email, rather than in the body of the email?
    Try this line to set the $mailsubject instead
    PHP Code:
    $mailsubject "Contact Form: {$subjects[$subject]}"
    I hope this gives you the answers you're looking for.

    -Helge

  7. #32
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Almost done...

    In post #14, where would you insert the email validation code?
    Bryan T. Villarin
    All Narfed Up My System Rig

  8. #33
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can I remove the Sender's Name, Sender's E-Mail, and Subject lines if I've already included them in the actual email headers now? If I remove those three lines, the from field shows "name@lr1.potentblablah.com".

    Code:
        if(empty($errorMsg) && array_key_exists($to, $sendto) && array_key_exists($subject, $subjects)) {
            $mailmsg = "Email Sent from btvillarin.com contact form\n";
            $mailmsg .= "Sender's Name:    $sendername\n";
            $mailmsg .= "Sender's E-Mail:  $senderemail\n";
            $mailmsg .= "Subject:          {$subjects[$subject]}\n";
            $mailmsg .= "Message:          $message\n\n";
    Thanks Helge!
    Bryan T. Villarin
    All Narfed Up My System Rig

  9. #34
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by btvillarin
    where would you insert the email validation code?
    The same place as you do the other validation.
    PHP Code:
    $errorMsg = array();
    if(empty(
    $sendername)) $errorMsg[] = 'Your name';
    if(empty(
    $senderemail)) $errorMsg[] = 'Your E-mail address';
    $searchstring "^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$^";
    if(
    preg_match($searchstring$senderemail)) $errorMsg[] = 'Your E-mail address is not in a valid format';
    if(empty(
    $to) || empty($sendto[$to])) $errorMsg[] = 'To';
    if(empty(
    $subject) || $subject == 0$errorMsg[] = 'Subject';
    if(empty(
    $message)) $errorMsg[] = 'Message'
    Quote Originally Posted by btvillarin
    How can I remove the Sender's Name, Sender's E-Mail, and Subject lines if I've already included them in the actual email headers now? If I remove those three lines, the from field shows "name@lr1.potentblablah.com".
    I don't understand what you mean here.
    I'm not sure if I answered this question
    AND, is there any way I can just have the subject to be shown in the actual headers of the email, rather than in the body of the email?
    correct. By headers do you mean subject or headers? I read it as subject when I answered it.

    -Helge

  10. #35
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind, the reason why it's showing that @potent stuff after the name (if a valid email address wasn't shown correctly) is because the server appends it.

    The email validation code doesn't work when I inserted it where you explained above.
    Bryan T. Villarin
    All Narfed Up My System Rig

  11. #36
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops think I forgot a !. Try
    PHP Code:
    if(!preg_match($searchstring$senderemail)) $errorMsg[] = 'Your E-mail address is not in a valid format'
    instead.

    -Helge

  12. #37
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That worked!

    But, if the name field has only one word, then it appends the server's domain name to it.

    (e.g. "Bryan@lr1.potentproducts.com")
    Bryan T. Villarin
    All Narfed Up My System Rig

  13. #38
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by btvillarin
    That worked!
    Good
    Quote Originally Posted by btvillarin
    But, if the name field has only one word, then it appends the server's domain name to it.

    (e.g. "Bryan@lr1.potentproducts.com")
    Where does that happen. In the email or form. Could you explain some more?

    -Helge

  14. #39
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the actual email when I just enter my first name. If I entered my first and last name, it went through fine.

    Envelope-to: bryan.nospam@btvillarin.com
    To: bryan.nospam@btvillarin.com
    Subject: Computer Consulting
    From: Bryan@lr1.potentproducts.com
    X-Mailer: btvillarin.com Contact Form 1.0
    Reply-To: bryan.nospam@btvillarin.com

    Email Sent from btvillarin.com contact form
    Test
    Bryan T. Villarin
    All Narfed Up My System Rig

  15. #40
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if that is something that is supposed to happens automatically. If it's not then it's a bit strange, because if you haven't altered the script in post 14, the following line is setting the from option in the mail header
    PHP Code:
    $mailheaders "From: btvillarin.com <> \n"
    And that one isn't including the name ($sendername) at all.

    -Helge

  16. #41
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed that line to:

    Code:
    $mailheaders = "From: $sendername\n";
    Is it incorrect?
    Bryan T. Villarin
    All Narfed Up My System Rig

  17. #42
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Taken and adapted from http://www.dclp-faq.de
    PHP Code:
    list($user$host) = explode("@"$sendermail);
    if (
    checkdnsrr($host"MX") or checkdnsrr($host"A")) {
        print 
    "the mail might work";
    } else {
        print 
    "the mail cant be sent";

    Just a note, actually you might not want to do this since it can take minutes and the user will think that the script broke. You could save the host into a table if it's valid and then further user which used the same host would pass without a new check. Oh, yeah, this code can't say if the mail account exists, so it still might be a fake account. The best way to test this is to have the user click on a activation link in a email.

  18. #43
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for posting Gaheris. I'm glad this thread got active.

    I probably won't take that course of action. If people post a wrong email address, then that's their fault. But at least if they don't type it in the format of an email address, the script will prompt them to correct it. That's all I'm drivin at.
    Bryan T. Villarin
    All Narfed Up My System Rig

  19. #44
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I understand. I wouldn't use it myself.
    I just wanted to add a bit, it might help somebody (yeah, right).

  20. #45
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still can't figure out why I am getting a left ">" angle bracket

  21. #46
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.
    Quote Originally Posted by btvillarin
    I changed that line to:

    Code:
    $mailheaders = "From: $sendername\n";
    Is it incorrect?
    Ok. Try this instead:
    PHP Code:
    $mailheaders "From: $sendername <$senderemail>\n"
    HTH

    -Helge

  22. #47
    SitePoint Zealot btvillarin's Avatar
    Join Date
    Nov 2002
    Location
    Arcadia, California
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooh, Helge...that'll work just fine! Thanks!
    Bryan T. Villarin
    All Narfed Up My System Rig


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •