ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Combining PHP form with Mailing List Module

December 01, 2011 12:23pm

Subscribe [2]
  • #1 / Dec 01, 2011 12:23pm

    inc11

    13 posts

    Hi all,
    Looking for some advice on the mailing list module, I have created a php form for a client, this form sends the client an email and stores the information in a .csv file. My issue is, the client want’s to also, grab the email address and save it into the expression engine mailing list module.

    My question is, how will I combine my php script with the expression engine mailing list module? Also, I don’t want to use the expression engine thank you page, I want the php form to run as it has been set up.

    My php script is:

    <?php
    $Name = $_POST['name']; //senders name
    $phonenum = $_POST['phonenum']; //senders phone number
    $email = $_POST['email'];
    $location = $_POST['location'];
    $noguests = $_POST['noguests'];
    $day = $_POST['day'];
    $month = $_POST['month'];
    $year = $_POST['year'];
    $hour = $_POST['hour'];
    $minute = $_POST['minute'];
    $addcom = $_POST['addcom'];
    
    $to = "[email protected]"; //recipient
    $fs = fopen("bookings.csv","a");
      fwrite($fs,"\n" . $Name . ", " . $phonenum . ", " . $email . ", " . $location . ", " . $noguests . ", " . $day . "-" . $month . "-" . $year . ", " . $hour . ":" . $minute . ", " . $addcom);
      fclose($fs);
    $subject = "Booking for ".$_POST['day']."-".$_POST['month']."-".$_POST['year']; //subject
    $message =  "Name: ".$_POST['name']."\r\n".
       "Phone Number: ".$_POST['phonenum']."\r\n".
       "Email: ".$_POST['email']."\r\n".
       "Location: ".$_POST['location']."\r\n".
       "Number Of Guests: ".$_POST['noguests']."\r\n".
       "Date: ".$_POST['day']."-".$_POST['month']."-".$_POST['year']."\r\n".
       "Time: ".$_POST['hour'].":".$_POST['minute']."\r\n".
       "Comments: ".$_POST['addcom']; //mail body
    $from = "Booking Form"; //
    $headers = "From: ".$from."\r\n"; //optional headerfields
     
    mail($to, $subject, $message, $headers); //mail command :blush: you can add any variable here… I know you have so many, but it is possible…
    ?>
    strong>Thank you…</strong>
    
    
    We will be in touch soon to confirm your booking.


    Thanks.

  • #2 / Dec 02, 2011 2:28pm

    Dan Decker

    7338 posts

    Hi incMarketing,

    The best way to get complete integration with ExpressionEngine and your script would be to migrate your script into a plug-in. As a plug-in, it would gain access to all aspects of ExpressionEngine and you could input the captured data into the mailing list database. You can find more information in our Developer Documentation.

    Thanks!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases