SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to get form to submit properly

    Hi all,

    I have a custom form I have created that lives in its own file. The file is linked to a WP page via a plugin called php-to-page (works great). I have this at the top of my form:

    <form action="http://www.adamsherman.com.au/postureperfection/thankyou/" method="post">

    but when I hit the submit button I get a 404.

    HOWEVER, when I copy the above url into my browser it works - I get to the right page (but without the posted info of course).

    I was wondering if anyone knew why this would be happening.

    You can test for yourself:

    http://adamsherman.com.au/postureper...ge/?prodid=323

    Thanks!

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Hi MeltingDog. Welcome to SitePoint.

    Clicking Submit on the form takes me to the thank you page (even with empty form fields, which you should avoid). It's odd to have the tahny you url as the action link. Are you sure that's what you want? What's in the index file of that folder? A script?

  3. #3
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ralph,

    Thanks for the response.

    Yes I havent put in any form validation yet as I am trying to get the basics of it working. Im not sure what you mean by 'tahny you url' I assume you mean entire URL? I have that in because I am using WP as a CMS. If I just put in /thankyou as the URL I would get:
    http://adamsherman.com.au/postureper...quiry/thankyou

    instead of:

    http://adamsherman.com.au/postureperfection/thankyou

    There is no index file in the folder - these are actually just wordpress pages but the content links out to a script. The 2 scripts (one that has the form one the product-enquiry page and the other processes the form on the thankyou page) are within their own folder without an index as this was unnecessary. I do not think it is a html or php issue (but could be wrong) as all other html and php I have created like this works fine.

    Thanks again for your reply!

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    OK, I obviously don't understand how this works, but I didn't get a 404 by clicking Submit, anyhow. When a form is submitted, do you get an email? What I meant above (sorry for the sloppy typing) was the the page referenced by the action="" is normally a PHP script of some sort. So I would not expect the URL of the thank you page to be there normally. But maybe that's a feature of the plugin.

  5. #5
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ralph,

    Very strange - the form seems to work for you? It just wont for me even if I clear my browsers cache and start again. Yeah I havent received any emails either - but when I paste the URL I do. Perhaps I will tear it all down and start again...very strange!

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by MeltingDog View Post
    Very strange - the form seems to work for you?
    Yes ... in as much as I click Submit and get the thank you message. But if you don't get an email at the end, then presumably there's nothing really happening, except that the form takes you to the thanks page. There must be a page at that thanks address, isn't there? What is actually in the file at this location?

    http://www.adamsherman.com.au/postureperfection/thankyou/

  7. #7
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The file at that location is as follows:

    $name = $_POST['name'];
    $email = $_POST['email'];
    $number = $_POST['number'];
    $comment = $_POST['comment'];
    $pcode = $_POST['pcode'];
    $product = $_POST['product'];
    $amount = $_POST['amount'];
    $formcontent="From: $name \n $email \n $number \n $pcode \n Item: $product Amount: $amount \n Message: $comment";
    $recipient = "myemail@hotmail.com";
    $subject = "Customer Enquiry from Posture Perfection Site";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You";

    I know it is not the neatest and that the thankyou string should be on its own page but I just want to get the damned thing working first!

    (just to try and make it a bit clearer as to how I have done this - the 'thankyou' page is acutally a wordpress page with the above code 'included()' into the page via the php-to-page plugin - hope that makes it a little clearer!)

  8. #8
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I have solved it!!!

    The reason why it was working for you (I beleive) is that you were just hitting submit without filling out the fields, whilst I was filling out all the fields. When I left the fields blank it worked. I then tested all the fields and found that the Name field was causing the error. I do not know why but perhaps $name is a reserved variable. I changed it to $customer and it works fine!

    Thanks for all your help Ralph!

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Glad you got it sorted!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •