Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP form Email

  • 03-04-2007 7:06pm
    #1
    Closed Accounts Posts: 4


    Hey i am at the moment making an application form to collect detailis from people using my site.
    What i want to happen is for the user to submit details that will be sent to a specified email address.The problem that i am having is when the user clicks submit a box appears saying that "The form is being submitted using email, Submitting this form will reveal youre-mail address to the recipient, and will send the form data without encrypting it for privacy" when user oks it. outlook pops up when you are in internet explorer saying its not currently you default.

    In Mozilla and Opera it does the same but at time says " To join an email club????"

    All i want it to do is send the info to a specified email address through php without having to setup outlook.

    Is there something i'm doing wrong?

    This is the main part of the php:
    <?
    $surname = $_POST ;
    $firstname = $_POST ;
    $extra = $_POST ;

    mail( "test mail@gmail.com", "Application form",
    "$mailString
    1 Personal Details

    Last name: $surname
    First name: $firstname

    Other Details

    $extra ",
    etc....
    $message, "From: $firstname <$email>" );
    header( "Location: /thankyou.html" );


    ?>


Comments

  • Registered Users, Registered Users 2 Posts: 568 ✭✭✭phil


    The problem is more than likely in the HTML you're using to POST to the form. Post that as well please, preferably within a code block (use vBulletins [ code ] [ /code ] blocks without the spaces)


  • Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭randombar


    Here's an example of one of mine:
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "newform")) {
    
    $pubname=$_POST['pubname'];
    $publoc=$_POST['publoc'];
    $pubemail=$_POST['pubemail'];
    $lat=$_POST['lat'];
    $long=$_POST['long'];
    
    	$emailto="ratemypub@gmail.com";
    	$subject="New Pub";
    	$message="Pub Link: http://www.ratemypub.ie/pub.php \n\n \n\n" ;
    	
    mail($emailto,$subject,$message);
    
    
     print "<script>";
     print " self.location='pub.php?pubid=$pubid';";
     print "</script>";
    }
    

    Inside in your form you need the hidden input
    <form action="<?php echo $editFormAction; ?>" name="form" method="POST">
    
    <input type="hidden" name="MM_insert" value="newform">
    
    </form>
    


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    What i want to happen is for the user to submit details that will be sent to a specified email address.
    mailto as an action will not work for when someone doesn't have a mailto application like Outlook.
    I use a web interface for my email so forms like this will simply not work for me (the DTO has the same thing; very annoying).
    Can you change it so that it invokes a script on the server and that script sends the email? Obviously it opens security issues but there are plenty of free scripts out there that can drop in.


  • Closed Accounts Posts: 4 SurferMonkey


    Not to sure what you mean have you any example code of a working form that is doing generally what i want mine to do?


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Not to sure what you mean have you any example code of a working form that is doing generally what i want mine to do?
    Here you are surfermonkey. Two seperate pages, call the form page whatever you want, and the second page sendmail.php (or whatever you want but be sure to change the action on the form) Includes validation.:

    [html]
    <form action="sendmail.php" method="post">
    <table valign="top">
    <tr>
    <td colspan="2">Please use this form to email your enquiries:</td>
    </tr>
    <tr>
    <td>Name:</td>
    <td><input name="name" value="<? echo $_POST; ?>"></td>
    </tr>
    <tr>
    <td>E-mail:</td>
    <td><input name="email" value="<? echo $_POST; ?>"></td>
    </tr>
    <tr>
    <td>Phone:</td>
    <td><input name="phone" value="<? echo $_POST; ?>"></td>
    </tr>
    <tr>
    <td>Enquiry:</td>
    <td><textarea name="enquiry" rows="6" cols="25"><? echo $_POST; ?></textarea></td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" name="submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    [/html]

    sendmail.php
    [php]

    <?

    echo '<div id="main">';

    if (isset($_POST)) {


    if(!$_POST || !$_POST || !$_POST || !$_POST) {


    echo 'The following fields are required:<br>';

    if(!$_POST) {
    echo 'Name<br>';
    }
    if(!$_POST) {
    echo 'Email<br>';
    }
    if(!$_POST) {
    echo 'Phone<br>';
    }
    if(!$_POST) {
    echo 'Enquiry<br>';
    }


    } else {

    $body = "Name: {$_POST} \nEmail: {$_POST} \nPhone: {$_POST} \n\nEnquiry: {$_POST}\n";

    $to = "youremail@gmail.com";
    $subject = "Enquiry from YourWebsite.com";
    $headers = "From: webmaster@yourwebsite.com\n";

    if(@mail($to,$subject,$body,$headers)) {
    echo "Thank you for your enquiry. We will respond in due course.";
    }else{
    echo '<br><br>There was an error sending the enquiry, please try again later, or use the following link: <a href="mailto: youremail@gmail.com">youremail@gmail.com</a><br><br>';
    }

    }


    }


    echo '</div>';

    ?>

    [/php]


  • Advertisement
  • Closed Accounts Posts: 4 SurferMonkey


    Hey thanks for that ill give it a try when i can get the time to work this thing


  • Registered Users, Registered Users 2 Posts: 2,591 ✭✭✭tommycahir


    It might be worth having a look @ the following premade script , i have been using on a few sites now without any issues

    http://www.tectite.com/


  • Registered Users, Registered Users 2 Posts: 2,919 ✭✭✭Bob the Builder


    tommycahir wrote:
    It might be worth having a look @ the following premade script , i have been using on a few sites now without any issues

    http://www.tectite.com/

    To add to that: http://www.tele-pro.co.uk/scripts/contact_form/index.htm


  • Registered Users, Registered Users 2 Posts: 568 ✭✭✭phil


    I've not even visited the pages where these scripts are, but please please be careful with the quality of scripts you download / use. Obviously most people are not programmers so auditing the code isn't possible.

    However, "due dilligence" in this case should be to research the scripts history, find referrals and make sure that it hasn't at least a history of security problems.

    I'm not saying anything about the above is good / bad, but from experience as a host, the amount of compromised accounts I've seen through the simple process of a customer installing a seemingly innocious CGI / PHP script is silly.

    Also remembering, any script you use you should be keeping an eye on for security alerts. If a script becomes deprecated / unmaintained, you need to start searching around for a replacement.

    Phil.


Advertisement