Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: mailform without confirmation

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default mailform without confirmation

    Hey all.
    I have the following mailform code:
    Code:
    <?php
    if ($_POST["action"] == "send"){
    if ($_POST[name] != " your name" and $_POST[name] != "" and $_POST[email] != " your e-mail adress" and $_POST[email] != "" and $_POST[message] != "") { 
    mail ("info@net.com", "via NET", 
    "
    Name: ".$_POST['name']."
    E-mail: ".$_POST['email']."
    Message: ".$_POST['message']."
    
    ",
    
    "From: ".$_POST['name']." <".$_POST['email'].">");
    
    $subject = "PLANET confirmation"; 
    
    $msg = "
    
    This is an automatically sent email. Please do not reply.
    Dear $_POST[name],
    Thanks for your message to NET.
    We will get back to you within two working days.
    
    This was your message:
    
    $_POST[message] 
    
    ";  
    
    
    
    mail($_POST[email], $subject, $msg); 
    
    
    echo '<br>&nbsp;<br>Thanks ! <br>&nbsp;<br>Your message has been sent,<br> and you will receive a confirmation mail. <br>&nbsp;<br>&nbsp;<br> NET will get back to you within two working days.<br>&nbsp;<br>&nbsp;<br>';
    
    }
    
    
    
    else{
    
    echo '<br>&nbsp;<br><font color="#565656;">Your mail has NOT been sent !</font><br>&nbsp;<br>Please fill in all data.<br>Your name, email adress and message are mandatory fields.<br>&nbsp;<br>&nbsp;<br><a href="about.php"><font color="#565656;">[again please]</font></a><br>&nbsp;<br>';
    
    }
    
    }
    
    ?>
    I would like the same code, but without the confirmation mail sent to the visitor (but with confirmation on the site). Can anyone help me, please ?

    In addition I'd need a mandatory select box (drop down) with different emails that are sent too.
    F.ex. you can chose between 'webmaster', 'director', 'sales' and then the mails are sent to web@, director@ and sales@
    Last edited by chechu; 10-24-2009 at 02:42 PM.

  2. #2
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    For the choice of who it is sent to, just create a dropdown menu in html inside the form: call it "to" and then in the PHP just use that $_POST['to'] as the person who gets the email. That is-- in the second line of code, replace "info@net.com" with $_POST['to'].

    To not send the email to the user, delete all this:
    Code:
    $subject = "PLANET confirmation"; 
    
    $msg = "
    
    This is an automatically sent email. Please do not reply.
    Dear $_POST[name],
    Thanks for your message to NET.
    We will get back to you within two working days.
    
    This was your message:
    
    $_POST[message] 
    
    ";  
    
    
    
    mail($_POST[email], $subject, $msg);
    That's all.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. The Following User Says Thank You to djr33 For This Useful Post:

    chechu (10-25-2009)

  5. #4
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Thanks Daniel. I do not understand the part where I need to call the menu "to". What needs to be added here ?

    Code:
    									<script type="text/JavaScript">
    
    									function clearDefault(el) {
    
    									if (el.defaultValue==el.value) el.value = ""
    
    									}
    
    									</script>
    
    									<form name="form1" method="post" action="contact.php">
    
    									<input type="hidden" name="action" value="send">
    									<table><tr><td align=left valign=top>
    									<input type="text" name="name" value=" your name" onfocus="clearDefault(this)" style="border-top:0px; border-left: 1px dotted #cc6600; border-right:0px; border-bottom: 1px dotted #cc6600; width:160px; margin-top:24px;">
    
    									<input type="text" name="email" value=" your email adress" onfocus="clearDefault(this)" style="border-top:0px; border-left: 1px dotted purple; border-right:0px; border-bottom: 1px dotted purple; width:160px; margin-top:20px;">
    
    										<select>
    										  <option>sales</option>
    										  <option>director</option>
    										  <option>web</option>
    									</select>									<img src="images/vink.gif" border="0" style="padding-left:10px; margin-top:26px;"><input type="submit" value="send" style="border:0px; background-color: #ffffff; margin-top:26px;">  
    
    									</td><td align=left valign=top>
    									<textarea name="message" style="border-top:0px; border-left:1px dotted #0066cc; border-right:0px; border-bottom: 1px dotted #0066cc; width:240px; height:96px; margin-top:24px;" onfocus="clearDefault(this)"> your message</textarea>
    
    									</td></tr></table>
    									</form>
    where "sales", "director" and "web", when chosen, should have the message sent to a different mail adres.

    So this then what the php looks like, right ?

    Code:
    <?php
    
    
    
    if ($_POST["action"] == "send"){
    
    
    
    if ($_POST[name] != " your name" and $_POST[name] != "" and $_POST[email] != " your e-mail adress" and $_POST[email] != "" and $_POST[message] != "") { 
    
    mail ("$_POST['to']", "via NET", 
    
    "
    
    Name: ".$_POST['name']."
    
    E-mail: ".$_POST['email']."
    
    Message: ".$_POST['message']."
    
    
    
    ",
    
    "From: ".$_POST['name']." <".$_POST['email'].">");
    
    
    
    echo '<br>&nbsp;<br>Thanks ! <br>&nbsp;<br>Your message has been sent,<br> and you will receive a confirmation mail. <br>&nbsp;<br>&nbsp;<br> NET will get back to you within two working days.<br>&nbsp;<br>&nbsp;<br>';
    
    
    
    }
    
    
    
    else{
    
    echo '<br>&nbsp;<br><font color="#565656;">Your mail has NOT been sent !</font><br>&nbsp;<br>Please fill in all data.<br>Your name, email adress and message are mandatory fields.<br>&nbsp;<br>&nbsp;<br><a href="about.php"><font color="#565656;">[again please]</font></a><br>&nbsp;<br>';
    
    }
    
    }
    
    ?>

  6. #5
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    I think

    Code:
    								
    <select name="to">
    <option value="salesemail@.com">sales</option>
    <option value="directoremail@.com">director</option>
    <option value="webemail@.com">web</option>
    </select>

  7. The Following User Says Thank You to bluewalrus For This Useful Post:

    chechu (10-25-2009)

  8. #6
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Works perfectly, thanks !
    I had made this mistake in the php:
    Code:
    mail ("$_POST['to']", "via NET",
    should be
    Code:
    mail ($_POST['to'], "via NET",
    Only thing is, now everyone can see the email adresses. Is there a way to have them in the php file instead of the html ?
    Last edited by chechu; 10-25-2009 at 09:27 PM.

  9. #7
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    I don't see anything wrong. I just ran a test with test in the fields and got success page. Are you getting an error page, email not being sent, email being sent incorrectly, nothing?

    Thanks !

    Your message has been sent,
    and you will receive a confirmation mail.


    CasalPLANET will get back to you within two working days.

  10. #8
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    I adjusted the error; see my post above.
    But can you do something about the following:

    1/ now everyone can see the email adresses. Is there a way to have them in the php file instead of the html ?
    2/ the select box is not mandatory now

    Thanks for your help !

  11. #9
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    yea put the values as 1, 2, 3 in the html. In php

    PHP Code:
    if ($_post['to'] === "1") { 
    $mail_to "sales@such.com";
    }

    if (
    $_post['to'] === "2") { 
    $mail_to "director@such.com";
    }
    if (
    $_post['to'] === "3") { 
    $mail_to "web@such.com";
    }

    mail ($mail_to"via NET",  keep the rest of your code the same from this point 
    For the being mandatory do you mean it doesn't process the data if the select isn't selected or it doesn't send.
    Last edited by bluewalrus; 10-25-2009 at 09:39 PM. Reason: spelt from wrong hah

  12. The Following User Says Thank You to bluewalrus For This Useful Post:

    chechu (10-25-2009)

  13. #10
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Like this ?

    Code:
    <?php
    if ($_POST["action"] == "send"){
    if ($_POST[name] != " your name" and $_POST[name] != "" and $_POST[email] != " your e-mail adress" and $_POST[email] != "" and $_POST[message] != "") { 
    mail (if ($_post['to'] === "1") { 
    $mail_to = "sales@such.com";
    }
    if ($_post['to'] === "2") { 
    $mail_to = "director@such.com";
    }
    if ($_post['to'] === "3") { 
    $mail_to = "web@such.com";
    }
    mail ($mail_to, "via NET",  "
    Name: ".$_POST['name']."
    E-mail: ".$_POST['email'].
    Message: ".$_POST['message']."
    ",
    "From: ".$_POST['name']." <".$_POST['email'].">");
    echo '<br>&nbsp;<br>Thanks ! <br>&nbsp;<br>Your message has been sent.<br>&nbsp;<br>&nbsp;<br> NET will get back to you within two working days.<br>&nbsp;<br>&nbsp;<br>';
    }
    else{
    echo '<br>&nbsp;<br><font color="#565656;">Your mail has NOT been sent !</font><br>&nbsp;<br>Please fill in all data.<br>Your name, email adress and message are mandatory fields.<br>&nbsp;<br>&nbsp;<br><a href="about.php"><font color="#565656;">[again please]</font></a><br>&nbsp;<br>';
    }
    }
    ?>
    And this:

    Code:
    <select name="to" style="width:160px; margin-top:26px;">
    <option selected value="who do you wish to contact">who do you wish to contact</option>
    <option value="1">sales</option>
    <option value="2">director</option>
    <option value="3">web</option>
    </select>
    Is the option field now a mandatory field ?

    How does it feel to talk to someone who has no clue what he is doing ?

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
  •