Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Member #
    30930
    I need to place an If/Else statement (or something similar) in a PHP script file I have, but am having trouble. I'm relatively new at Web design so please be specific; I think this is a pretty easy fix, I just am not getting the code right.

    My PHP file is taking information constituents fill out in an online form, and sends the info to someone through an e-mail. Here is what my PHP file looks like (sections of it):

    $DLocation1 = $_REQUEST['DLocation1'];
    $DAddress1 = $_REQUEST['DAddress1'];
    $DCity1 = $_REQUEST['DCity1'];
    $DState1 = $_REQUEST['DState1'];
    $DZip1 = $_REQUEST['DZip1'];
    $DPhone1 = $_REQUEST['DPhone1'];
    $DTime1 = $_REQUEST['DTime1'];

    $DLocation2 = $_REQUEST['DLocation2'];
    $DAddress2 = $_REQUEST['DAddress2'];
    $DCity2 = $_REQUEST['DCity2'];
    $DState2 = $_REQUEST['DState2'];
    $DZip2 = $_REQUEST['DZip2'];
    $DPhone2 = $_REQUEST['DPhone2'];
    $DTime2 = $_REQUEST['DTime2'];


    // Email body content
    $content =

    .'First Stop: '.$DLocation1."\n"
    .'Address: '.$DAddress1."\n"
    .'City: '.$DCity1."\n"
    .'State: '.$DState1."\n"
    .'Zip Code: '.$DZip1."\n"
    .'Phone: '.$DPhone1."\n"
    .'Arrival Time: '.$DTime1."\n\n"

    .'Second Stop: '.$DLocation2."\n"
    .'Address: '.$DAddress2."\n"
    .'City: '.$DCity2."\n"
    .'State: '.$DState2."\n"
    .'Zip Code: '.$DZip2."\n"
    .'Phone: '.$DPhone2."\n"
    .'Arrival Time: '.$DTime2."\n\n"

    This works fine, but all of my text ("First stop", "Address", etc.) prints out for ALL of the fields (there are many more than this), even if the constituent does not fill out all of the fields in the form. So my client gets a loong e-mail with the unnecessary text.

    What I want is an If/Else statement to say: IF the "DLocation2" field has information, then place in the e-mail:
    .'Second Stop: '.$DLocation2."\n" If the textfield is blank, then don't submit anything and go on to the next field. And I'll do this for all of the fields.

    Can you help? I have to get this figured out in the next few days and other forums didn't know what to do!

    thanks!

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    1) If your <form> method is, method="post", don't use $_REQUEST, use $_POST instead.

    For the content ... something similar to this ....
    PHP Code:
    <?php

    $content
    ="";
    if(
    $_POST['DLocation1']){
    $content .= "First Stop: ".$_POST['DLocation1']."\n";
    }
    if(
    $_POST['DAdress1']){
    $content .= "First Address: ".$_POST['DAddress1']."\n";
    }
    if(
    $_POST['DCity1']){
    $content .= "First City: ".$_POST['DCity1']."\n";
    }

    // etc.

    // This will keep building on the $content string ... adding only what exists.

    // Make an "if" statement for all of them ...

    // then put $content in your email ...

    ?>
    EDIT:
    And what REALLY SHOULD happen is the information goes into a MySQL database, not an email.
    The admin person or whoever can access the database for a list of constituents. That database
    can then be used for making changes to their profile ... like a mistake with the address. And
    it can also be used for many other things pertaining to the constituent.

    If the person filling out the form puts wrong information in, what do they do? Email and
    somehow fix the mistake? So then you have a dozen emails back and forth, and you're not
    sure what information is correct and what is not correct. Emails are a bad way to do this.


  4. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Member #
    30930
    I'm not sure why the e-mail method was chosen. Probably because the guy who designed this didn't really know what he was doing (not that I'm any better). I'm trying to work with what I have until they redesign the site in a year or so.

    I used your code, but the form doesn't send with the changes. It was set up as a REQUEST method, so I left that as is. Is that my problem? Should I change the form to POST? I left the first stop as is since those fields are required. It is the additional stops that are optional. Here is what my code looks like now:

    $content =
    .'Today\'s Date: '.$today."\n\n"

    .'First Stop: '.$DLocation1."\n"
    .'Address: '.$DAddress1."\n"
    .'City: '.$DCity1."\n"
    .'State: '.$DState1."\n"
    .'Zip Code: '.$DZip1."\n"
    .'Phone: '.$DPhone1."\n"
    .'Arrival Time: '.$DTime1."\n\n"

    }
    if($_REQUEST['DLocation2']){
    $content .= "Second Stop: ".$_REQUEST['DLocation2']."\n";
    }
    if($_REQUEST['DAdress2']){
    $content .= "Address: ".$_REQUEST['DAddress2']."\n";
    }
    if($_REQUEST['DCity2']){
    $content .= "City: ".$_REQUEST['DCity2']."\n";
    }
    if($_REQUEST['DState2']){
    $content .= "State: ".$_REQUEST['DState2']."\n";
    }
    if($_REQUEST['DZip2']){
    $content .= "Zip: ".$_REQUEST['DZip2']."\n";
    }
    if($_REQUEST['DPhone2']){
    $content .= "Phone: ".$_REQUEST['DPhone2']."\n";
    }
    if($_REQUEST['DTime2']){
    $content .= "Time: ".$_REQUEST['DTime2']."\n";
    }

    .'Comments: '.$comment."\n\n"

    Is it not working because I'm using two different kinds of code (the top is a different format the the bottom)?

    Thanks so much for your help.

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    The top part will need to have $_POST in them ...
    and remove the extra bracket (see red bracket below) ...

    Your form should say. <form method="post" ...... >

    $content =
    .'Today\'s Date: '.$today."\n\n"

    do that for all of the top ones.

    .'First Stop: '.$_POST['sdfdsf']."\n"
    .'Address: '.$DAddress1."\n"
    .'City: '.$DCity1."\n"
    .'State: '.$DState1."\n"
    .'Zip Code: '.$DZip1."\n"
    .'Phone: '.$DPhone1."\n"
    .'Arrival Time: '.$DTime1."\n\n"

    }
    if($_REQUEST['DLocation2']){
    $content .= "Second Stop: ".$_REQUEST['DLocation2']."\n";
    }


  6. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Member #
    30930
    Currently the top says this:

    if ($_SERVER['REQUEST_METHOD'] == 'GET')
    {
    header('Location: ../index.htm'); // Main page
    exit();
    }

    Do I remove this entire code and replace it with <form method="post">, or do I place that somewhere in there?

  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Post the entire script that has the form ....


  8. #7
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Member #
    30930
    Here is the PHP file. It works fine, but I want everything to print out like it is, with the exception of the stops (I have another form that allows up to six stops..I'm sending you the smaller form). As mentioned previously, the first stop is required but I want the additional stops to only print in the email if the constituent fills out those fields.

    PHP Code:
    <?php
    /* * ************************************************************************* * *
      *  filename    : xamail.php                                                  *
    * *  begin      : Thursday, September 20, 2007  17:14:25 p.m.                * *
      *  copyright  : (C) 2007                                                    *
      *  email      : xamibo@gmail.com                                            *
      *                                                                            *
      *  This program is FREE software; you can redistribute it and/or modify      *
      *  it under the terms of the GNU General Public License as published by      *
    * *  the Free Software Foundation; either version 2 of the License, or        * *
      *  (at your option) any later version.                                      *
    * * ************************************************************************* * */

    // Prevent direct access to this file from a URL and redirect to another page
    if ($_SERVER['REQUEST_METHOD'] == 'GET')
    {
        
    header('Location: ../index.htm'); // Main page
        
    exit();
    }

    // Embedded information
    //putenv('TZ=CTUINT'); // Central time
    $date_time date("F j, Y, g:i:s a T"); // Time and Date
    $ip_address $_SERVER["REMOTE_ADDR"];  // get user ip address
    $user_agent $_SERVER['HTTP_USER_AGENT'];
    $sub $_SERVER['HTTP_REFERER'];      // use form link as subject title

    // Variables
    $trip_date $_REQUEST['demo1'];
    $today $_REQUEST['dte_today'];
    $AM_PM_1 $_REQUEST['L_T2'];
    $AM_PM_2 $_REQUEST['R_T2'];
    $trip_time $_REQUEST['TotalTime'];
    $confirmation $_REQUEST['confirmation_num'];
    $contact_person $_REQUEST['contact_person'];
    $coordinator_num $_REQUEST['trip_coordinator'];
    $address $_REQUEST['address'];
    $city $_REQUEST['city'];
    $state $_REQUEST['state'];
    $zip_code $_REQUEST['zip'];
    $ph1 $_REQUEST['phone1'];
    $ph2 $_REQUEST['phone2'];
    $ph3 $_REQUEST['phone3'];
    $email $_REQUEST['email'];
    $group_name $_REQUEST['group_name'];
    $pr_location $_REQUEST['pr_location'];
    $pr_address $_REQUEST['pr_address'];
    $pr_city $_REQUEST['pr_city'];
    $pr_state $_REQUEST['pr_state'];
    $pr_zip $_REQUEST['pr_zip'];

    $DLocation1 $_REQUEST['DLocation1'];
    $DAddress1 $_REQUEST['DAddress1'];
    $DCity1 $_REQUEST['DCity1'];
    $DState1 $_REQUEST['DState1'];
    $DZip1 $_REQUEST['DZip1'];
    $DPhone1 $_REQUEST['DPhone1'];
    $DTime1 $_REQUEST['DTime1'];

    $DLocation2 $_REQUEST['DLocation2'];
    $DAddress2 $_REQUEST['DAddress2'];
    $DCity2 $_REQUEST['DCity2'];
    $DState2 $_REQUEST['DState2'];
    $DZip2 $_REQUEST['DZip2'];
    $DPhone2 $_REQUEST['DPhone2'];
    $DTime2 $_REQUEST['DTime2'];

    $fixedChairs $_REQUEST['FW_1'];
    $chairTrans $_REQUEST['WT_1'];
    $totalPassengers $_REQUEST['passenger_num'];

    $comment $_REQUEST['comment'];

    // Send email
    //$to = $_REQUEST['toEmail'];
    $form_name "SAP Multi-Care Facility Trip Reservation";  // Form name or title
    //$to = "eH@XX.net";            // *Do not forget to change email
    $to "RT@XX.net";            //*Do not forget to change email
    $from $email;                            // Where is it from
    $subject $form_name;                    // Subject title
     
    // Email body content
    $content =
    'Multi-Care Facility Trip Information            '."\n\n"

    .'Today\'s Date:              '.$today."\n\n"

    .'Date of Trip:              '.$trip_date."\n"
    .'Departure Time:            '.$AM_PM_1."\n"
    .'Estimated Return Time:    '.$AM_PM_2."\n"
    .'Total Trip Time:          '.$trip_time." hours\n\n"

    .'Confirmation Number:      '.$confirmation."\n"
    .'Trip Coordinator:          '.$contact_person."\n"
    .'Address:                  '.$address."\n"
    .'City:                      '.$city."\n"
    .'State:                    '.$state."\n"
    .'Zip code:                  '.$zip_code."\n"
    .'Primary phone:            '.$ph1."\n"
    .'Work phone:                '.$ph2."\n"
    .'Cell phone:                '.$ph3."\n"
    .'E-mail:                    '.$email."\n"
    .'Group Name:                '.$group_name."\n\n"
    .'Pick-up/Return Location:  '.$pr_location."\n"
    .'Pick-up/Return Address:    '.$pr_address."\n"
    .'City:                      '.$pr_city."\n"
    .'State:                    '.$pr_state."\n"
    .'Zip code:                  '.$pr_zip."\n\n"

    .'First Stop:                '.$DLocation1."\n"
    .'Address:                    '.$DAddress1."\n"
    .'City:                        '.$DCity1."\n"
    .'State:                    '.$DState1."\n"
    .'Zip Code:                    '.$DZip1."\n"
    .'Phone:                      '.$DPhone1."\n"
    .'Arrival Time:                '.$DTime1."\n\n"

    .'Second Stop:              '.$DLocation2."\n"
    .'Address:                    '.$DAddress2."\n"
    .'City:                      '.$DCity2."\n"
    .'State:                    '.$DState2."\n"
    .'Zip Code:                  '.$DZip2."\n"
    .'Phone:                      '.$DPhone2."\n"
    .'Arrival Time:                '.$DTime2."\n\n"

    .'Fixed Wheelchairs:          '.$fixedChairs."\n"
    .'Wheelchair Transfers:      '.$chairTrans."\n"
    .'Total # of Passengers:      '.$totalPassengers."\n\n"

    .'Comments:                '.$comment."\n\n"

    // Agent
    .'Date/Time:                '.$date_time."\n"
    .'IP Address:                '.$ip_address."\n"
    .'User Agent:                '.$user_agent."\n";

    $header "From: ".$from."\n"
      
    "MIME-Version: 1.0\n"
      
    "Content-type: text/plain; charset=\"ISO-88-1\"\n"
      
    "Content-transfer-encoding: 8bit\n";

    // Send mail here
    if(mail($to$subject$content$header))
    {
        
    header('Location: ../senioradult/daytrips/thankyou_multi.htm');
    }

    //
    //end of mail function
    //
     
    ?>

  9. #8
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    I would probably use an array for the stops, but that can be changed later on.

    In this example, if they enter anything in the first box of the stops (DLocation),
    it will print that stop section, otherwise it won't show.

    PHP Code:
    <?php
    /* * ************************************************************************* * *
      *  filename    : xamail.php                                                  *
    * *  begin      : Thursday, September 20, 2007  17:14:25 p.m.                * *
      *  copyright  : (C) 2007                                                    *
      *  email      : xamibo@gmail.com                                            *
      *                                                                            *
      *  This program is FREE software; you can redistribute it and/or modify      *
      *  it under the terms of the GNU General Public License as published by      *
    * *  the Free Software Foundation; either version 2 of the License, or        * *
      *  (at your option) any later version.                                      *
    * * ************************************************************************* * */

    // Prevent direct access to this file from a URL and redirect to another page
    if ($_SERVER['REQUEST_METHOD'] == 'GET')
    {
        
    header('Location: ../index.htm'); // Main page
        
    exit();
    }

    // Embedded information
    //putenv('TZ=CTUINT'); // Central time
    $date_time date("F j, Y, g:i:s a T"); // Time and Date
    $ip_address $_SERVER["REMOTE_ADDR"];  // get user ip address
    $user_agent $_SERVER['HTTP_USER_AGENT'];
    $sub $_SERVER['HTTP_REFERER'];      // use form link as subject title

    // Variables
    $trip_date $_REQUEST['demo1'];
    $today $_REQUEST['dte_today'];
    $AM_PM_1 $_REQUEST['L_T2'];
    $AM_PM_2 $_REQUEST['R_T2'];
    $trip_time $_REQUEST['TotalTime'];
    $confirmation $_REQUEST['confirmation_num'];
    $contact_person $_REQUEST['contact_person'];
    $coordinator_num $_REQUEST['trip_coordinator'];
    $address $_REQUEST['address'];
    $city $_REQUEST['city'];
    $state $_REQUEST['state'];
    $zip_code $_REQUEST['zip'];
    $ph1 $_REQUEST['phone1'];
    $ph2 $_REQUEST['phone2'];
    $ph3 $_REQUEST['phone3'];
    $email $_REQUEST['email'];
    $group_name $_REQUEST['group_name'];
    $pr_location $_REQUEST['pr_location'];
    $pr_address $_REQUEST['pr_address'];
    $pr_city $_REQUEST['pr_city'];
    $pr_state $_REQUEST['pr_state'];
    $pr_zip $_REQUEST['pr_zip'];

    $DLocation1 $_REQUEST['DLocation1'];
    $DAddress1 $_REQUEST['DAddress1'];
    $DCity1 $_REQUEST['DCity1'];
    $DState1 $_REQUEST['DState1'];
    $DZip1 $_REQUEST['DZip1'];
    $DPhone1 $_REQUEST['DPhone1'];
    $DTime1 $_REQUEST['DTime1'];

    $DLocation2 $_REQUEST['DLocation2'];
    $DAddress2 $_REQUEST['DAddress2'];
    $DCity2 $_REQUEST['DCity2'];
    $DState2 $_REQUEST['DState2'];
    $DZip2 $_REQUEST['DZip2'];
    $DPhone2 $_REQUEST['DPhone2'];
    $DTime2 $_REQUEST['DTime2'];

    $DLocation3 $_REQUEST['DLocation3'];
    $DAddress3 $_REQUEST['DAddress3'];
    $DCity3 $_REQUEST['DCity3'];
    $DState3 $_REQUEST['DState3'];
    $DZip3 $_REQUEST['DZip3'];
    $DPhone3 $_REQUEST['DPhone3'];
    $DTime3 $_REQUEST['DTime3'];

    $DLocation4 $_REQUEST['DLocation4'];
    $DAddress4 $_REQUEST['DAddress4'];
    $DCity4 $_REQUEST['DCity4'];
    $DState4 $_REQUEST['DState4'];
    $DZip4 $_REQUEST['DZip4'];
    $DPhone4 $_REQUEST['DPhone4'];
    $DTime4 $_REQUEST['DTime4'];

    $DLocation5 $_REQUEST['DLocation5'];
    $DAddress5 $_REQUEST['DAddress5'];
    $DCity5 $_REQUEST['DCity5'];
    $DState5 $_REQUEST['DState5'];
    $DZip5 $_REQUEST['DZip5'];
    $DPhone5 $_REQUEST['DPhone5'];
    $DTime5 $_REQUEST['DTime5'];

    $DLocation6 $_REQUEST['DLocation6'];
    $DAddress6 $_REQUEST['DAddress6'];
    $DCity6 $_REQUEST['DCity6'];
    $DState6 $_REQUEST['DState6'];
    $DZip6 $_REQUEST['DZip6'];
    $DPhone6 $_REQUEST['DPhone6'];
    $DTime6 $_REQUEST['DTime6'];

    $fixedChairs $_REQUEST['FW_1'];
    $chairTrans $_REQUEST['WT_1'];
    $totalPassengers $_REQUEST['passenger_num'];

    $comment $_REQUEST['comment'];

    // Send email
    //$to = $_REQUEST['toEmail'];
    $form_name "SAP Multi-Care Facility Trip Reservation";  // Form name or title
    //$to = "eH@XX.net";            // *Do not forget to change email
    $to "RT@XX.net";            //*Do not forget to change email
    $from $email;                            // Where is it from
    $subject $form_name;                    // Subject title
     
    // Email body content
    $content =
    'Multi-Care Facility Trip Information            '."\n\n"

    .'Today\'s Date:              '.$today."\n\n"

    .'Date of Trip:              '.$trip_date."\n"
    .'Departure Time:            '.$AM_PM_1."\n"
    .'Estimated Return Time:    '.$AM_PM_2."\n"
    .'Total Trip Time:          '.$trip_time." hours\n\n"

    .'Confirmation Number:      '.$confirmation."\n"
    .'Trip Coordinator:          '.$contact_person."\n"
    .'Address:                  '.$address."\n"
    .'City:                      '.$city."\n"
    .'State:                    '.$state."\n"
    .'Zip code:                  '.$zip_code."\n"
    .'Primary phone:            '.$ph1."\n"
    .'Work phone:                '.$ph2."\n"
    .'Cell phone:                '.$ph3."\n"
    .'E-mail:                    '.$email."\n"
    .'Group Name:                '.$group_name."\n\n"
    .'Pick-up/Return Location:  '.$pr_location."\n"
    .'Pick-up/Return Address:    '.$pr_address."\n"
    .'City:                      '.$pr_city."\n"
    .'State:                    '.$pr_state."\n"
    .'Zip code:                  '.$pr_zip."\n\n";

    // this stop is required ...
    $content =
    .
    'First Stop:                '.$DLocation1."\n"
    .'Address:                    '.$DAddress1."\n"
    .'City:                        '.$DCity1."\n"
    .'State:                    '.$DState1."\n"
    .'Zip Code:                    '.$DZip1."\n"
    .'Phone:                      '.$DPhone1."\n"
    .'Arrival Time:                '.$DTime1."\n\n";

    if(
    $DLocation2){
    $content =
    .
    'Second Stop:              '.$DLocation2."\n"
    .'Address:                    '.$DAddress2."\n"
    .'City:                      '.$DCity2."\n"
    .'State:                    '.$DState2."\n"
    .'Zip Code:                  '.$DZip2."\n"
    .'Phone:                      '.$DPhone2."\n"
    .'Arrival Time:                '.$DTime2."\n\n";
    }
    if(
    $DLocation3){
    $content =
    .
    'Third Stop:              '.$DLocation3."\n"
    .'Address:                    '.$DAddress3."\n"
    .'City:                      '.$DCity3."\n"
    .'State:                    '.$DState3."\n"
    .'Zip Code:                  '.$DZip3."\n"
    .'Phone:                      '.$DPhone3."\n"
    .'Arrival Time:                '.$DTime3."\n\n";
    }
    if(
    $DLocation4){
    $content =
    .
    'Fourth Stop:              '.$DLocation4."\n"
    .'Address:                    '.$DAddress4."\n"
    .'City:                      '.$DCity4."\n"
    .'State:                    '.$DState4."\n"
    .'Zip Code:                  '.$DZip4."\n"
    .'Phone:                      '.$DPhone4."\n"
    .'Arrival Time:                '.$DTime4."\n\n";
    }
    if(
    $DLocation5){
    $content =
    .
    'Fifth Stop:              '.$DLocation5."\n"
    .'Address:                    '.$DAddress5."\n"
    .'City:                      '.$DCity5."\n"
    .'State:                    '.$DState5."\n"
    .'Zip Code:                  '.$DZip5."\n"
    .'Phone:                      '.$DPhone5."\n"
    .'Arrival Time:                '.$DTime5."\n\n";
    }
    if(
    $DLocation6){
    $content =
    .
    'Sixth Stop:              '.$DLocation6."\n"
    .'Address:                    '.$DAddress6."\n"
    .'City:                      '.$DCity6."\n"
    .'State:                    '.$DState6."\n"
    .'Zip Code:                  '.$DZip6."\n"
    .'Phone:                      '.$DPhone6."\n"
    .'Arrival Time:                '.$DTime6."\n\n";
    }

    $content =
    .
    'Fixed Wheelchairs:          '.$fixedChairs."\n"
    .'Wheelchair Transfers:      '.$chairTrans."\n"
    .'Total # of Passengers:      '.$totalPassengers."\n\n"

    .'Comments:                '.$comment."\n\n"

    // Agent
    .'Date/Time:                '.$date_time."\n"
    .'IP Address:                '.$ip_address."\n"
    .'User Agent:                '.$user_agent."\n";

    $header "From: ".$from."\n"
      
    "MIME-Version: 1.0\n"
      
    "Content-type: text/plain; charset=\"ISO-88-1\"\n"
      
    "Content-transfer-encoding: 8bit\n";

    // Send mail here
    if(mail($to$subject$content$header))
    {
        
    header('Location: ../senioradult/daytrips/thankyou_multi.htm');
    }

    //
    //end of mail function
    //
     
    ?>


  10. #9
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Member #
    30930
    Sorry to bother you again, and I really appreciate your help and feel like I'm soo close to getting it right, but something still isn't right, as the form won't go through with these changes. I tried adding one change in at a time to see what was wrong, and I couldn't get past the first code addition without the form failing. I entered in the second $content variable here:
    PHP Code:
    ;

    // this stop is required ...
    $content 
    But it didn't work. I thought maybe I can't have two $content variables so I made a new name for the second instance ($content2) but that didn't help either. Why can't I insert a new variable? I added the semicolon before and there is one after towards the bottom. I even copied your code here in case I was missing something, but it still doesn't send the form through..I just get a blank web page after submitting the form (no confirmation it sent), and nothing in my inbox.

    thanks,
    HCP4

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Sorry, the $content thing was my fault ... see the altered script below.

    I messed up and forgot to append to $content by using .=
    PHP Code:
    <?php
    /* * ************************************************************************* * *
      *  filename    : xamail.php                                                  *
    * *  begin      : Thursday, September 20, 2007  17:14:25 p.m.                * *
      *  copyright  : (C) 2007                                                    *
      *  email      : xamibo@gmail.com                                            *
      *                                                                            *
      *  This program is FREE software; you can redistribute it and/or modify      *
      *  it under the terms of the GNU General Public License as published by      *
    * *  the Free Software Foundation; either version 2 of the License, or        * *
      *  (at your option) any later version.                                      *
    * * ************************************************************************* * */

    // Prevent direct access to this file from a URL and redirect to another page
    if ($_SERVER['REQUEST_METHOD'] == 'GET')
    {
        
    header('Location: ../index.htm'); // Main page
        
    exit();
    }

    // Embedded information
    //putenv('TZ=CTUINT'); // Central time
    $date_time date("F j, Y, g:i:s a T"); // Time and Date
    $ip_address $_SERVER["REMOTE_ADDR"];  // get user ip address
    $user_agent $_SERVER['HTTP_USER_AGENT'];
    $sub $_SERVER['HTTP_REFERER'];      // use form link as subject title

    // Variables
    $trip_date $_REQUEST['demo1'];
    $today $_REQUEST['dte_today'];
    $AM_PM_1 $_REQUEST['L_T2'];
    $AM_PM_2 $_REQUEST['R_T2'];
    $trip_time $_REQUEST['TotalTime'];
    $confirmation $_REQUEST['confirmation_num'];
    $contact_person $_REQUEST['contact_person'];
    $coordinator_num $_REQUEST['trip_coordinator'];
    $address $_REQUEST['address'];
    $city $_REQUEST['city'];
    $state $_REQUEST['state'];
    $zip_code $_REQUEST['zip'];
    $ph1 $_REQUEST['phone1'];
    $ph2 $_REQUEST['phone2'];
    $ph3 $_REQUEST['phone3'];
    $email $_REQUEST['email'];
    $group_name $_REQUEST['group_name'];
    $pr_location $_REQUEST['pr_location'];
    $pr_address $_REQUEST['pr_address'];
    $pr_city $_REQUEST['pr_city'];
    $pr_state $_REQUEST['pr_state'];
    $pr_zip $_REQUEST['pr_zip'];

    $DLocation1 $_REQUEST['DLocation1'];
    $DAddress1 $_REQUEST['DAddress1'];
    $DCity1 $_REQUEST['DCity1'];
    $DState1 $_REQUEST['DState1'];
    $DZip1 $_REQUEST['DZip1'];
    $DPhone1 $_REQUEST['DPhone1'];
    $DTime1 $_REQUEST['DTime1'];

    $DLocation2 $_REQUEST['DLocation2'];
    $DAddress2 $_REQUEST['DAddress2'];
    $DCity2 $_REQUEST['DCity2'];
    $DState2 $_REQUEST['DState2'];
    $DZip2 $_REQUEST['DZip2'];
    $DPhone2 $_REQUEST['DPhone2'];
    $DTime2 $_REQUEST['DTime2'];

    $DLocation3 $_REQUEST['DLocation3'];
    $DAddress3 $_REQUEST['DAddress3'];
    $DCity3 $_REQUEST['DCity3'];
    $DState3 $_REQUEST['DState3'];
    $DZip3 $_REQUEST['DZip3'];
    $DPhone3 $_REQUEST['DPhone3'];
    $DTime3 $_REQUEST['DTime3'];

    $DLocation4 $_REQUEST['DLocation4'];
    $DAddress4 $_REQUEST['DAddress4'];
    $DCity4 $_REQUEST['DCity4'];
    $DState4 $_REQUEST['DState4'];
    $DZip4 $_REQUEST['DZip4'];
    $DPhone4 $_REQUEST['DPhone4'];
    $DTime4 $_REQUEST['DTime4'];

    $DLocation5 $_REQUEST['DLocation5'];
    $DAddress5 $_REQUEST['DAddress5'];
    $DCity5 $_REQUEST['DCity5'];
    $DState5 $_REQUEST['DState5'];
    $DZip5 $_REQUEST['DZip5'];
    $DPhone5 $_REQUEST['DPhone5'];
    $DTime5 $_REQUEST['DTime5'];

    $DLocation6 $_REQUEST['DLocation6'];
    $DAddress6 $_REQUEST['DAddress6'];
    $DCity6 $_REQUEST['DCity6'];
    $DState6 $_REQUEST['DState6'];
    $DZip6 $_REQUEST['DZip6'];
    $DPhone6 $_REQUEST['DPhone6'];
    $DTime6 $_REQUEST['DTime6'];

    $fixedChairs $_REQUEST['FW_1'];
    $chairTrans $_REQUEST['WT_1'];
    $totalPassengers $_REQUEST['passenger_num'];

    $comment $_REQUEST['comment'];

    // Send email
    //$to = $_REQUEST['toEmail'];
    $form_name "SAP Multi-Care Facility Trip Reservation";  // Form name or title
    //$to = "eH@XX.net";            // *Do not forget to change email
    $to "RT@XX.net";            //*Do not forget to change email
    $from $email;                            // Where is it from
    $subject $form_name;                    // Subject title

    // Email body content
    $content =
    'Multi-Care Facility Trip Information            '."\n\n"

    .'Today\'s Date:              '.$today."\n\n"

    .'Date of Trip:              '.$trip_date."\n"
    .'Departure Time:            '.$AM_PM_1."\n"
    .'Estimated Return Time:    '.$AM_PM_2."\n"
    .'Total Trip Time:          '.$trip_time." hours\n\n"

    .'Confirmation Number:      '.$confirmation."\n"
    .'Trip Coordinator:          '.$contact_person."\n"
    .'Address:                  '.$address."\n"
    .'City:                      '.$city."\n"
    .'State:                    '.$state."\n"
    .'Zip code:                  '.$zip_code."\n"
    .'Primary phone:            '.$ph1."\n"
    .'Work phone:                '.$ph2."\n"
    .'Cell phone:                '.$ph3."\n"
    .'E-mail:                    '.$email."\n"
    .'Group Name:                '.$group_name."\n\n"
    .'Pick-up/Return Location:  '.$pr_location."\n"
    .'Pick-up/Return Address:    '.$pr_address."\n"
    .'City:                      '.$pr_city."\n"
    .'State:                    '.$pr_state."\n"
    .'Zip code:                  '.$pr_zip."\n\n";

    // this stop is required ...
    $content .=
    .
    'First Stop:                '.$DLocation1."\n"
    .'Address:                    '.$DAddress1."\n"
    .'City:                        '.$DCity1."\n"
    .'State:                    '.$DState1."\n"
    .'Zip Code:                    '.$DZip1."\n"
    .'Phone:                      '.$DPhone1."\n"
    .'Arrival Time:                '.$DTime1."\n\n";

    if(
    $DLocation2){
    $content .=
    .
    'Second Stop:              '.$DLocation2."\n"
    .'Address:                    '.$DAddress2."\n"
    .'City:                      '.$DCity2."\n"
    .'State:                    '.$DState2."\n"
    .'Zip Code:                  '.$DZip2."\n"
    .'Phone:                      '.$DPhone2."\n"
    .'Arrival Time:                '.$DTime2."\n\n";
    }
    if(
    $DLocation3){
    $content .=
    .
    'Third Stop:              '.$DLocation3."\n"
    .'Address:                    '.$DAddress3."\n"
    .'City:                      '.$DCity3."\n"
    .'State:                    '.$DState3."\n"
    .'Zip Code:                  '.$DZip3."\n"
    .'Phone:                      '.$DPhone3."\n"
    .'Arrival Time:                '.$DTime3."\n\n";
    }
    if(
    $DLocation4){
    $content .=
    .
    'Fourth Stop:              '.$DLocation4."\n"
    .'Address:                    '.$DAddress4."\n"
    .'City:                      '.$DCity4."\n"
    .'State:                    '.$DState4."\n"
    .'Zip Code:                  '.$DZip4."\n"
    .'Phone:                      '.$DPhone4."\n"
    .'Arrival Time:                '.$DTime4."\n\n";
    }
    if(
    $DLocation5){
    $content .=
    .
    'Fifth Stop:              '.$DLocation5."\n"
    .'Address:                    '.$DAddress5."\n"
    .'City:                      '.$DCity5."\n"
    .'State:                    '.$DState5."\n"
    .'Zip Code:                  '.$DZip5."\n"
    .'Phone:                      '.$DPhone5."\n"
    .'Arrival Time:                '.$DTime5."\n\n";
    }
    if(
    $DLocation6){
    $content .=
    .
    'Sixth Stop:              '.$DLocation6."\n"
    .'Address:                    '.$DAddress6."\n"
    .'City:                      '.$DCity6."\n"
    .'State:                    '.$DState6."\n"
    .'Zip Code:                  '.$DZip6."\n"
    .'Phone:                      '.$DPhone6."\n"
    .'Arrival Time:                '.$DTime6."\n\n";
    }

    $content .=
    .
    'Fixed Wheelchairs:          '.$fixedChairs."\n"
    .'Wheelchair Transfers:      '.$chairTrans."\n"
    .'Total # of Passengers:      '.$totalPassengers."\n\n"

    .'Comments:                '.$comment."\n\n"

    // Agent
    .'Date/Time:                '.$date_time."\n"
    .'IP Address:                '.$ip_address."\n"
    .'User Agent:                '.$user_agent."\n";

    $header "From: ".$from."\n"
      
    "MIME-Version: 1.0\n"
      
    "Content-type: text/plain; charset=\"ISO-88-1\"\n"
      
    "Content-transfer-encoding: 8bit\n";

    // Send mail here
    if(mail($to$subject$content$header))
    {
        
    header('Location: ../senioradult/daytrips/thankyou_multi.htm');
    }

    //
    //end of mail function
    //

    ?>



Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:46 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com