We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6004
    • 28 Posts
    I have a form that is submitting to itself (typical php stuff) but when the form is submitted it is just reloading the page. It doesn’t appear to be setting any variables or executing the code it should be in the if() statement. My code is below.

    if (isset($_POST['submit'])) {
    
    extract($_POST);
    
    $subject = "Contact from Firefly website";
    $headers = "From: $firstName $lastName <$email>";
    
    $to = $to . "@fireflylightinginnovations.com";
    
    $message = "Email from:" . "\r\n";
    $message .= "$firstName $lastName" . "\r\n";
    $message .= "$title" . "\r\n";
    $message .= "$company" . "\r\n";
    $message .= "$phone" . "\r\n";
    $message .= "$email" . "\r\n" . "\r\n";
    $message .= "Message:" . "\r\n";
    $message .= "$mess";
    
    /* mail($to, $subject, $message, $headers); */
    echo "$to<br />$headers<br /><br />$message";
    
    echo '<h3>Thank you!</h3> <p>Your message has been sent.  Someone will contact you within 2 business days.</p>';
    
    } else {
    
    echo $_SERVER['PHP_SELF'];
    
    echo "<form action=\"".$_SERVER['PHP_SELF']."?id=6\" method=\"post\">";
    echo '
    <label>Send message to:</label> <select name="to">
    	<option value="">Select a Recipient</option>
    	<option value="sales">Sales</option>
    	<option value="engineering">Engineering</option>
    	<option value="marketing">Marketing</option>
    	<option value="service">Customer Service</option>
    </select><br />
    <br />
    <input type="text" name="firstName" size="20" /> <label>First Name</label><br />
    <input type="text" name="lastName" size="20" /> <label>Last Name</label><br />
    <br />
    <input type="text" name="title" size="20" /> <label>Title</label><br />
    <input type="text" name="company" size="20" /> <label>Company Name</label><br />
    <input type="text" name="phone" size="20" /> <label>Phone Number</label><br />
    <input type="text" name="email" size="20" /> <label>Email Address</label><br />
    <br />
    <textarea name="mess" rows="10" cols="20">Please use this area to type your message.</textarea>
    
    <input type="submit" value="Send Message" name="submit" />
    
    </form>';
    
    }
    


    What is going on? This works fine when I try it outside of modx...
      • 25663 MODX Staff
      • 12,272 Posts
      Is the page cached?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 6004
        • 28 Posts
        I cleared the cache and tried it...still the same thing.

        You can try it here-- http://fireflylightinginnovations.com/index.php?id=6
          • 25663 MODX Staff
          • 12,272 Posts
          Is the checkbox on the page in the manager on the page settings tab when editing the page next to the word "cacheable" checked is what I mean. Forms cannot be on cached pages, as they have to be processed every time.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 6004
            • 28 Posts
            aahhhhh....i did not realize that. I’m new to ModX.

            I unchecked it, cleared the cache and now it’s working good.

            Thanks a lot!