Results 1 to 13 of 13
  1. #1
    Join Date
    Jul 2006
    Posts
    1,078

    Form Handler Help

    Hi Guys

    Ive made a PHP contact form but cant seem to make a handler that works

    the PHP form code:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Email Form </title>
    <style type="text/css">
    <!--
    .style1 {
     font-family: Verdana;
     font-size: 12px;
    }
    -->
    </style>
    </head>
    <body>
    <form action="sendemail.php" method="post" class="style1">
     
      <div align="left">Your Name: 
        <input type="text" name="visitor" size="35" />
        <br />
        <br />
    Your Email:
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />
    Department
    :
    <select name="attn" size="1">
      <option value=" Sales n Billing ">Sales n Billing </option> 
      <option value=" General Support ">General Support </option> 
      <option value=" Technical Support ">Technical Support </option> 
      <option value=" Webmaster ">Webmaster </option> 
    </select>
    <br />
    <br/>
    Mail Message:
    <br />
    <textarea name="notes" rows="4" cols="40"></textarea>
    <br/>
    <br/>
    Your IP:<?php echo $ipi ?><br />
    <br/>
    <input type="submit" value="Send Mail" />
    <br/>
      </div>
    </form>
    </body>
    </html>
    I need a handler where if they select sales it sends to [email protected] and if you choose techinical it sends to [email protected] etc

    Many thanks

  2. #2
    Join Date
    Jul 2006
    Posts
    1,078
    Also can someone help get the your IP part working so it displays in a box

    Thanks

  3. #3
    Join Date
    Jul 2006
    Posts
    1,078
    Anyone? (longer message)

  4. #4
    Join Date
    Oct 2002
    Location
    Dubuque, IA, USA
    Posts
    29
    Can you describe the problem you are having a little better? I can probably help if I can figure out what you are looking for.

    Also, I'm not sure I understand what you mean about putting the IP address in a box. Do you mean in an input box, or you just want it surrounded by an outline?

    --
    JBreits

  5. #5
    Join Date
    Jul 2006
    Posts
    1,078
    IP Address in an Input box

    The problem i am having is i cannot get it to send to multiple addresses depending on what department they have chosen to send it to

    So if they choose sales it will send to the sales email adress and if they choose support it will send to the support email address etc

  6. #6
    Join Date
    Oct 2002
    Location
    Dubuque, IA, USA
    Posts
    29

  7. #7
    Join Date
    Jul 2006
    Posts
    1,078
    the way itl work is if they choose sales it sends to sales and if they choose support it sends to support

    Could anyone right me a handler for this script

  8. #8
    Join Date
    Oct 2002
    Location
    Dubuque, IA, USA
    Posts
    29
    You need to do something like the following in the handler:

    if ($_POST['attn'] == ' Sales n Billing ')
    {
    $to = [email protected]';
    }
    elseif ($_POST['attn'] == ' General Support ')
    {
    $to = [email protected]';
    }
    elseif ....


    Then you just send the e-mail to whoever is stored in $to.

    --
    JBreits

  9. #9
    Join Date
    Jul 2006
    Posts
    1,078
    Could someone write one please as my php coding of form handlers is not brilliant

  10. #10
    Join Date
    Jul 2006
    Posts
    1,078
    So far ive got

    Contact.php:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Email Form </title>
    <style type="text/css">
    <!--
    .style1 {
     font-family: Verdana;
     font-size: 12px;
    }
    -->
    </style>
    </head>
    <body>
    <form action="sendeail.php" method="post" class="style1">
     
      <div align="left">Your Name: 
        <input type="text" name="visitor" size="35" />
        <br />
        <br />
    Your Email:
    <input type="text" name="visitormail" size="35" />
    <br />
    <br />
    Department
    :
    <select name="attn" size="1">
      <option value=" Sales n Billing ">Sales n Billing </option> 
      <option value=" General Support ">General Support </option> 
      <option value=" Technical Support ">Technical Support </option> 
      <option value=" Webmaster ">Webmaster </option> 
    </select>
    <br />
    <br/>
    Mail Message:
    <br />
    <textarea name="notes" rows="4" cols="40"></textarea>
    <br/>
    <br/>
    <input type="text" name="ipaddress" size="35" value="<?php echo $ipi ?>" />
    <br/>
    <input type="submit" value="Send Mail" />
    <br/>
      </div>
    </form>
    </body>
    </html>
    The IP address doesnt work


    and the formhandler which doesnt work:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Sendemail Script</title>
    </head>
    <body>
    <!-- Reminder: Add the link for the 'next page' (at the bottom) --> 
    <!-- Reminder: Change 'YourEmail' to Your real email --> 
    <?php
    if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
    {
    echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    }
    if(empty($visitor) || empty($visitormail) || empty($notes )) {
    echo "<h2>Use Back - fill in all fields</h2>\n";
    }
    $todayis = date("l, F j, Y, g:i a") ;
    $attn = $attn ; 
    $subject = $attn; 
    $notes = stripcslashes($notes); 
    $message = " $todayis [EST] \n
    Attention: $attn \n
    Message: $notes \n 
    From: $visitor ($visitormail)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";
    $from = "From: $visitormail\r\n";
    
    mail if ($_POST['attn'] == ' Sales n Billing ')
    {
    $to = [email protected]';
    }
    elseif ($_POST['attn'] == ' General Support ')
    {
    $to = [email protected]';
    }
    elseif ($_POST['attn'] == ' Webmaster ')
    {
    $to = [email protected]';
    }
    ($subject, $message, $from);
    ?>
    <p align="center">
    Date: <?php echo $todayis ?> 
    <br />
    Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
    <br />
    Attention: <?php echo $attn ?>
    <br /> 
    Message:<br /> 
    <?php $notesout = str_replace("\r", "<br/>", $notes); 
    echo $notesout; ?> 
    <br />
    <?php echo $ip ?> 
    <br /><br />
    <a href="thankyou.php"> Next Page </a> 
    </p> 
    </body>
    </html>

  11. #11
    Join Date
    Mar 2005
    Location
    Minneapolis, MN
    Posts
    881

    Thumbs up

    here is something that will make your ip show up
    Code:
     <?php echo $_SERVER["REMOTE_ADDR"]; ?>
    that works I tested your script I notice you had an error line 34 now I got another mail script for you that works great .. has features just like yours .. it just has alot more to it .. but it's more easier to understand ..
    Mrgeekchris.com ~ It's not just a job It's a passion
    "Mistakes are proof that you are trying"

  12. #12
    Join Date
    Jul 2006
    Posts
    1,078
    Cheers

    Can we see your script

    as you can see my PHP isnt great lol

  13. #13
    Join Date
    Jul 2006
    Posts
    1,078
    anyone else able to help?

Posting Permissions

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