Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    57
    Thanks
    15
    Thanked 1 Time in 1 Post

    Half of page missing

    If input is submited blank an error msg comes up but only half the page shows:

    Code:
    <!-- Top html -->
    
    <?php
    // Check if the user submitted this form
    if($_POST['submit'])
           {
    	   
    //  Change HTML code so hackers cant f*ck you over eg: < to &lt;
    $_POST['input'] = htmlspecialchars($_POST['input']);
    
    //  Check if input field is blank
    
    if (empty($_POST['input'])) {
    
    	die('Error msg!');
    }
    // Open the file in write mode
           $handle = fopen("inc/$list","a"); 
    
    // If successful
    if ($handle) {
    // Write to that handle the input submitted
            fwrite($handle, $_POST['input'] . PHP_EOL); 
                
    // Close
            fclose($handle);
    }   
    ?>
    
    <p><?php echo $success;?></p>
    
    <?php 
    } 
    else 
    { 
    ?>
    		
    <!-- Form is here -->
    
    <?php
    }
    ?>
    
    <!-- Bottom html -->
    it stops at the end of error msg so Bottom half of the html is missing ...
    Last edited by buggy; 01-26-2010 at 06:32 AM.
    Newbie at most things ...Hey we all gotta start somewhere right :)

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    try

    if (isset($_POST['email'])) {


    same for submit

    if(isset($_POST['submit'])) {

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    57
    Thanks
    15
    Thanked 1 Time in 1 Post
    Quote Originally Posted by seco View Post
    try

    if (isset($_POST['email'])) {


    same for submit

    if(isset($_POST['submit'])) {
    made no effect thanks anyway ...
    Newbie at most things ...Hey we all gotta start somewhere right :)

  • #4
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    http://www.php.net/exit - die() is an alias for exit()

    It's working as it should, what else did you expect?

    What you should be doing is collecting error messages, in an array for instance... then display the layout with the expected output, modifying it if errors were collected:
    PHP Code:
    <?php

    $errors 
    = array();

    if ( ! isset( 
    $_POST['input'] ) || empty( $_POST['input'] ) )
    {
        
    $errors[] = 'input is empty!';
    }

    ?>
    <html>
    ...
    <?php if ( count$errors ) ): ?>
        Errors were detected:<br />
        <?php echo implode'<br />'$errors );
    <?
    php else: ?>
        Display page as expected...
    <?php endif; ?>
    ...
    </html>
    Last edited by kbluhm; 01-25-2010 at 08:54 PM.

  • #5
    New Coder
    Join Date
    Jun 2008
    Posts
    57
    Thanks
    15
    Thanked 1 Time in 1 Post
    Thanks both of you but I got it sorted myself
    Newbie at most things ...Hey we all gotta start somewhere right :)

  • #6
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Oh... well then, forget what we said.

    Why remove the original issue? What if someone else comes along with a similar problem? I wouldn't consider this your own personal support department, and I'm sure it gets annoying when the questions get redundant.

    I mean, the topics in these forums -- as well as many others like it -- are archived and crawled by search engines. I'll bet it's awesome to pull up a topic and see nothing but edit: Resolved!, and then a bunch of solutions that have no coherence.
    Last edited by kbluhm; 01-25-2010 at 09:57 PM.

  • #7
    New Coder
    Join Date
    Jun 2008
    Posts
    57
    Thanks
    15
    Thanked 1 Time in 1 Post
    Quote Originally Posted by kbluhm View Post
    Oh... well then, forget what we said.

    Why remove the original issue? What if someone else comes along with a similar problem? I wouldn't consider this your own personal support department, and I'm sure it gets annoying when the questions get redundant.

    I mean, the topics in these forums -- as well as many others like it -- are archived and crawled by search engines. I'll bet it's awesome to pull up a topic and see nothing but edit: Resolved!, and then a bunch of solutions that have no coherence.
    Put problem back to the best of my ability for you
    Newbie at most things ...Hey we all gotta start somewhere right :)


  •  

    Posting Permissions

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