Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress blank page on form submission, No plugin just PHP

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #198979
    Thadley
    Participant

    For my personal website, I am trying to learn a bit more about forms and PHP validations rather than use a plugin. It’s a simple form with a $fullname, $email, $subject, $website, $message and a normal submit button.

    I linked a codepen just to show you my PHP and HTML. I couldn’t get them to show up in here for some reason.

    link

    I have read that leaving the action=”” attribute empty will basically just refresh the page whenever the form is submitted. My website is simply one page so I don’t really need it to redirect me to another page.

    The PHP that checks if the fields are empty work because it revealed the appropriate message, although for obvious reasons, having them display before the user attempts to submit anything is pointless.

    I’m not sure if the IF statement surrounding the empty IF statements is right but either way when I click submit button, it refreshes the page and its now an empty blank white page with no HTML. The URL localhost:8888/wordpress stayed the same though except its a blank page.

    This is really annoying me and no matter what I try I get the same result. Any ideas what I’m doing wrong and is this a specific wordpress issue?

    #198982
    Paulie_D
    Member

    There’s obviously something in your content that the forum doesn’t like.

    Try making sure that any commands or code or whatever are wrapped in backticks like the example right below this box where it says “Posting Code”

    <script>
      function example() {
        element.innerHTML = "<div>code</div>";
      }
    </script>
    

    Please don’t keep starting new threads when whatever you are doing isn’t taking effect properly.

    #198984
    Senff
    Participant

    In wp-config.php, change this line:

    define('WP_DEBUG', false);
    

    To this:

    define('WP_DEBUG', true);
    

    Try again and see if there are any PHP errors now that may give you some clues.

    #198999
    Thadley
    Participant

    @Senff It is already on and it isn’t showing any errors that makes sense. The only errors are regarding the variable that contains the hidden submitted input below. :s

    $_POST['submitted'];
    
    


    @Paulie_D
    Well considering the new thread is about a different issue, I would see this as being a good idea. Why would I keep posting in a CSS thread I created for example when its a PHP problem and a completely different problem?

    #199163
    Thadley
    Participant

    I figured it out. In the reading section of wordpress, I set it to use a page for my front page instead of having it set to “your latest posts” only because I don’t have a blog yet.

    I had all my code inside the page.php file instead of the index.php file so whenever I hit submit, it would refresh and essentially load the blank index page. I just transferred all my code into the index file, adjusted my file paths and put it back to “your latest posts” so that it would read the index file and it worked. Everything is good for now :) I just thought I would update my thread.

    #199165
    Alen
    Participant

    @Thadley, you can look at the Template Hierarchy on Codex. It’s a great guide to how WP templating works. You can also create your own custom templates, which is a great way to handle multiple variations of page templates. Hope that’s helpful. Alen.

    #199811
    Sagive SEO
    Participant

    since your using WordPress i would skip the whole refresh page to submit a form and use ajax…

    That makes the whole error checking simpler and also helps you avoid the refresh which is just 1990.

    Here is the HTML code: http://pastebin.com/iwe8WESv
    Here is JS code: http://pastebin.com/vYzAy0kA
    Here is the PHP code: http://pastebin.com/AShhpZek

    Place JS & PHP file in a folder named “ajax” in your theme folder, include the PHP file in your functions.php file and your done.

    Best of luck ;)

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.