We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2091
    • 44 Posts
    Okay, this is really weird. When I click submit on this form it doesn’t submit. It just reloads the page and displays the empty form. So, I fill the form out again, and this time it works.

    Now, what’s even weirder is that after the form submitted, I copied the url and pasted it into IE just to test it there. And it showed my thank you message, as if I had submitted the form. WTF?

    Any help on this would be greatly appreciated.

    <?php
    print '<h1>Mission Trip Application</h1>';
    if(isset($_POST['submit']))
    {
    $area_1 = $_POST['area_1'];
    $area_3 = $_POST['area_3'];
    $area_2 = $_POST['area_2'];
    $area_4 = $_POST['area_4'];
    $dates_1 = $_POST['dates_1'];
    $dates_3 = $_POST['dates_3'];
    $dates_2 = $_POST['dates_2'];
    $dates_4 = $_POST['dates_4'];
    $medical = $_POST['medical'];
    $dental = $_POST['dental'];
    $evangelism = $_POST['evangelism'];
    $construction = $_POST['construction'];
    $medical_title = $_POST['medical_title'];
    $contact_time = $_POST['contact_time'];
    $contact_type = $_POST['contact_type'];
    $name = $_POST['name'];
    $work_phone = $_POST['work_phone'];
    $home_phone = $_POST['home_phone'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zip = $_POST['zip'];
    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From:' . $name . ' - <' . $email . '>' . "\r\n";
    $subject = 'Evangelistic International Ministries - Mission Trip Application';
    $message = '<h1>Mission Trip Application</h1>
    <table border="0" width="600px">
      <tr>
        <td colspan="2">I am interested in the following geographical areas:</td>
      </tr>
      <tr>
        <td width="232">1. ' . $area_1 . '</td>
        <td width="190">3.  ' . $area_3 . '</td>
      </tr>
      <tr>
        <td>2.  ' . $area_2 . '</td>
        <td>4.  ' . $area_4 . '</td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td colspan="2">The possible dates or time of year that I would most likely be available:</td>
      </tr>
      <tr>
        <td>1.  ' . $dates_1 . '</td>
        <td>3.  ' . $dates_3 . '</td>
      </tr>
      <tr>
        <td>2.  ' . $dates_2 . '</td>
        <td>4.  ' . $dates_4 . '</td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td colspan="2">I would be interested in a: </td>
      </tr>
      <tr>
        <td colspan="2"> ' . $medical . '</td>
      </tr>
      <tr>
        <td colspan="2"> ' . $dental . '</td>
      </tr>
      <tr>
        <td colspan="2"> ' . $evangelism . '</td>
      </tr>
      <tr>
        <td colspan="2"> ' . $construction . '</td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td>What is your medical title and specialty?</td>
        <td> ' . $medical_title . '</td>
      </tr>
      <tr>
        <td valign="top">Best time to contact:</td>
        <td>
             ' . $contact_time . '
        <br />
             ' . $contact_type . '</td>
      </tr>
      <tr>
        <td>Name:</td>
        <td> ' . $name . '</td>
      </tr>
       <tr>
        <td>Work Phone:</td>
        <td> ' . $work_phone . '</td>
      </tr>
       <tr>
        <td>Home Phone:</td>
        <td> ' . $home_phone . '</td>
      </tr>
       <tr>
        <td>Email:</td>
        <td> ' . $email . '></td>
      </tr>
      <tr>
        <td>Address:</td>
        <td> ' . $address . '</td>
      </tr>
      <tr>
        <td>City:</td>
        <td> ' . $city . '</td>
      </tr>
       <tr>
        <td>State:</td>
        <td> ' . $state . '</td>
      </tr>
       <tr>
        <td>Zip:</td>
        <td> ' . $zip . '</td>
      </tr>
    
    </table>';
    
    if(isset($medical))
    {
    $to = '...';
    }
    else
    {
    $to = '...';
    }
    
    mail($to, $subject, $message, $headers);
    
    print 'Thank you';
    }
    else
    {
    print '<form method="post">
    <table border="0">
      <tr>
        <td colspan="2">I am interested in the following geographical areas:</td>
      </tr>
      <tr>
        <td width="232">1. <input type="text" name="area_1" /></td>
        <td width="190">3. <input type="text" name="area_3" /></td>
      </tr>
      <tr>
        <td>2. <input type="text" name="area_2" /></td>
        <td>4. <input type="text" name="area_4" /></td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td colspan="2">The possible dates or time of year that I would most likely be available:</td>
      </tr>
      <tr>
        <td>1. <input type="text" name="dates_1" /></td>
        <td>3. <input type="text" name="dates_3" /></td>
      </tr>
      <tr>
        <td>2. <input type="text" name="dates_2" /></td>
        <td>4. <input type="text" name="dates_4" /></td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td colspan="2">I would be interested in a: </td>
      </tr>
      <tr>
        <td colspan="2"><input type="checkbox" name="medical" value="Medical/Surgical"/>Medical/Surgical</td>
      </tr>
      <tr>
        <td colspan="2"><input type="checkbox" name="dental" value="Dental"/>Dental</td>
      </tr>
      <tr>
        <td colspan="2"><input type="checkbox" name="evangelism" value="Evangelism"/>Evangelism</td>
      </tr>
      <tr>
        <td colspan="2"><input type="checkbox" name="construction" value="Construction Project" />Construction Project</td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td>What is your medical title and specialty?</td>
        <td><input type="text" name="medical_title" /></td>
      </tr>
      <tr>
        <td valign="top">Best time to contact:</td>
        <td>
            <input type="text" name="contact_time" />
        <br />
            <input type="radio" name="contact_type" value="Home" />
            Home   
            <input type="radio" name="contact_type" value="Work" />
        Work</td>
      </tr>
      <tr>
        <td>Name:</td>
        <td><input type="text" name="name" /></td>
      </tr>
       <tr>
        <td>Work Phone:</td>
        <td><input type="text" name="work_phone" /></td>
      </tr>
       <tr>
        <td>Home Phone:</td>
        <td><input type="text" name="home_phone" /></td>
      </tr>
       <tr>
        <td>Email:</td>
        <td><input type="text" name="email" /></td>
      </tr>
      <tr>
        <td>Address:</td>
        <td><input type="text" name="address" /></td>
      </tr>
      <tr>
        <td>City:</td>
        <td><input type="text" name="city" /></td>
      </tr>
       <tr>
        <td>State:</td>
        <td><input type="text" name="state" /></td>
      </tr>
       <tr>
        <td>Zip:</td>
        <td><input type="text" name="zip" /></td>
      </tr>
       <tr>
        <td></td>
        <td><input type="submit" name="submit" value="Submit" /></td>
      </tr>
    </table>
    </form>';
    }
    ?>
      • 10487 MODX Staff
      • 1,535 Posts
      Is this part of a snippet? If so, have you made sure you have the page set to uncachable (or calling the snippet uncached) - if you have caching set on one of them, you could well have issues when trying to use $_POST and $_GET variables in snippets.
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 2091
        • 44 Posts
        Ah, that did it. Thanks!