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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2010
    Posts
    285
    Thanks
    11
    Thanked 1 Time in 1 Post

    PHP Code not Echoing in if statement

    I have a registration page I built and if I leave a field empty nothing gets echoed telling me it's empty like my code is supposed to be set up like. For instance if I leave the username field empty, then it's supposed to say "You can't leave the username field empty." Can anyone tell me what's going on?



    Code:
    <?php
    if(version_compare(PHP_VERSION, "5.2.0", ">")){
    
        include('config.php');
    
    
    
        if($_SERVER['REQUEST_METHOD'] == "POST"){
            if($_POST['user']==""){
                echo "You can't leave the username field empty.<br />";
                } elseif($_POST['password'] == ""){
                    echo "You can't leave the password field empty.<br />";
                }elseif($_POST['confirm_password'] == ""){
                    echo "You can't leave the confirmation password field empty.<br />";
                    }elseif ($_POST['email'] == "" ){
                        echo "You can't leave the email field empty.<br />";
                    }elseif($_POST['confirm_email'] == ""){
                        echo "YOu can't leave the confirmation email field empty.<br />";
                        }elseif($_POST['password'] != $_POST['confirm_password']){
                            echo "Password does not match.<br />";
    
                        }elseif($_POST['confirm_password'] != $_POST['password']){
    
                            echo "Password does not match.<br />";
    
                            }elseif($_POST['email'] != $_POST['confirm_email']){
                                echo "Email does not match";
    
    
                                }elseif($_POST['confrim_email'] != $_POST['email']){
                                echo "Email does not match";
    
                                }else{
    
    
                    echo "Everything is correct and not empty.";
    
                    }
            }else{
    
    
    
    
    
                ?><form action="" method"POST">
                <input type="text" name="user"><br />
                 <input type="password" name="password"><br />
                 <input type="password" name="confirm_password"><br />
                 <input type="email" name="email"><br />
                 <input type="email" name="confirm_email"><br />
                <button type="submit">Sign Up</button>
                </form><?php
    
            }
        }else{
    
            ?> Please update your Php Version to suit these code settings<?php
    
                }
            ?>

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,557
    Thanks
    11
    Thanked 337 Times in 335 Posts
    Code:
    <form action="" method="POST">
    You're missing an "=" there, I don't think the form is ever getting posted.

  • Users who have thanked tracknut for this post:

    andynov123 (02-22-2015)

  • #3
    Regular Coder
    Join Date
    Oct 2010
    Posts
    285
    Thanks
    11
    Thanked 1 Time in 1 Post
    Thanks that fixed it. Nice catch!


  •  

    Tags for this Thread

    Posting Permissions

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