Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it's best to understand what's going on in a form submission, and dispel the idea that some magic is happening here.</p> <p>With form submissions, you're working with a work flow of sorts: </p> <ol> <li>HTML Form</li> <li>Processing Script</li> <li>Thank You Page.</li> </ol> <p>Each is a page, and the browser must be told to go to each page. Knowing this, if there is ever a problem, you can mentally walk through each step. You can also see this activity by looking a debug tools like Firefox Web Console (CTRL + SHIFT + K), Chrome Developer Tools (CTRL + SHIFT + J), and IE Developer Tools (F12).</p> <p><strong>Step 1 -> Step 2</strong></p> <p>The loading of the page in Step 2, the processing script, is accomplished through the action attribute of the form you have, which it looks like you may already know. However, the URL the form was originally submitting to looked a little funny. It should be pointing to a file on the server, I would expect "contactus.php". With "contactus.php/contactus.php", Apache Web Server must be translating the URL, moving the second "contactus.php" into the querystring.</p> <p>In your example, you changed this action to "thankyou.php", which would effectively skip loading the processing script in step 2 entirely, as was experienced.</p> <p><strong>Step 2 -> Step 3</strong></p> <p>As others have suggested, using PHP's <a href="http://php.net/manual/en/function.header.php" rel="nofollow">header</a> method (<code>header("LOCATION: thankyou.php")</code>) in place of <code>exit("Email sent successfully.");</code> is a good solution. This is telling the browser to go to "thankyou.php" by setting the HTTP header. This is a <code>key: value</code> format, with LOCATION being a special key the browser acts upon.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThanks, but as I've answered twice above, when I used the code all of you have provided, it doesn't direct me to "thankyou.php", it just keeps directing me to "contactus.php/contactus.php", and all the content on the page is the same content that was in "contacts.php", only it all looks weird, like there is no css being applied to anything, even though I know for absolute fact that I have the stylesheet links included on both pages. What is going on?
      singulars
    2. COIt sounds like it's not hitting the redirect. I would try having the script exit right before the redirect to see if it's getting there. If it is, then check the network log from one of the debug tools I listed to see if it's going to thankyou.php at all. In regards to the CSS, I think this is because of the URL "contactus.php/contactus.php". The first "contactus.php" is treated as a directory, which messes with relative URLs (styles.css vs /styles.css). It would be good to clean up that URL.
      singulars
    3. COOk so I don't know what I did, but now the URL at least says "contactus.php/thankyou.php", the content still isn't from thankyou.php though, it is all from "contactus.php". I just don't understand why if I have it redirecting only to "thankyou.php", why "contactus.php/thankyou.php" would even show up. The "thankyou.php" page isn't a subitem of "contactus.php"...Also in dreamweaver it keeps telling me there is a problem with my dynamically related files now, but this message is only showing up on my PHP pages, and there is nothing wrong with my file set up.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload