I have a template form which I have used and re-used many times successfully. However, after uploading my most recent variant it displays the form OK, but on clicking the submit button it displays a white page containing the last few lines of the code from the php form handler. My template works as follows: I have an html page to display the fields and tick boxes.
The form section is preceeded by the usual <form action="filename.php" method ="post">. This sends the information to the php form handler which has always worked in the past, of course I always modify the form handler to match the input from the html form.
I checked and rechecked against my successful versions of the form and cannot find a difference.

Have any of you experts experienced the white page containing the last few lines of the php code?

Awestruck

    it would be helpful if you troubleshot this first. I suggest you do the following:

    1. move or rename the page - see if you get a 404 - shows caching is not the problem.
    2. have filename.php just contain the word "test" - shows that the file is now in place.
    3. now, add the following code:
    echo '<pre>';
    print_r($_POST); //shows that your variables are there
    
    1. NOW, gently and carefully start adding your code in until you trap the error. You'll have a much more concise and clear post for the folks here who have helped me a lot too 🙂 but it is work nonetheless.

    Samuel

      Hm.. Sounds like you may have placed a php end tag somewhere in your code, which stops it from outputting a valid HTML document, because the last lines are not processed. Search your code, and make sure there is no ?> in the middle (Hint: This is most likely on the lines just above the code that the page displays)

        Many thanks for the prompt reply, I have noted your suggestion as it will be really handy for future problem solving. Meanwhile I found out what the problem was. I failed to look at the first line on the handler, it was different from all my other handlers; it had <?php whereas all my others had <?

        I changed the handler to <? and bingo I was in business. Can anyone explain why this caused the problem?

        Awestruck

          Are you sure it was not the other way around?

          <? is the short version of <?php

          Note: <?php is the recommended version, as <? may cause conflicts with other language processors.

            Hello Leatherback

            I agree with you that <?php is correct, but removing the php bit solved the problem. When I have a bit of spare time I will explore this aspect further. In my case, I think perhaps it is something to do with host's parser, using <?php I only received the white page with the last few lines of my php code. As soon as I removed the php bit it started to parse my code. The parser found two small errors. I corrected these and then the form was up and running. Weird?
            Many thanks
            Awestruck

              In my case, I think perhaps it is something to do with host's parser, using <?php I only received the white page with the last few lines of my php code. As soon as I removed the php bit it started to parse my code. The parser found two small errors. I corrected these and then the form was up and running. Weird?

              Very weird. <?php is one of the two ways of beginning a block of PHP code that is guaranteed to work regardless of the PHP configuration and external languages.

                5 days later

                After getting the form to work by removing the php, I uploaded it again and include the php. This time it worked, I don't think I will ever get to the bottom of that mystery.
                Thanks for your help and advice.
                Awesruck

                  Write a Reply...