0

My form is not working when I submit the form the names for example nickname dose not work it equals as a 0 when i try isset it shows true

   if(isset($_POST['name'])) {echo 'name!';} else {echo 'no!';} 

    <form action="signup-form.php" method="post" class="form-horizontal" id="form-signup">
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">Name</label>
            <div class="col-sm-10">
                <input type="name" class="form-control" id="name" placeholder="Name" name="name" />
            </div>
        </div>
        <div class="form-group">
            <label for="nickname" class="col-sm-2 control-label">Nickname</label>
            <div class="col-sm-10">
                <input type="nickname" class="form-control" id="nickname" placeholder="Nickname" name="nickname" />
            </div>
        </div>
        <div class="form-group">
            <label for="email" class="col-sm-2 control-label">Email</label>
            <div class="col-sm-10">
                <input type="email" class="form-control" id="email" placeholder="Email" name="email" />
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">Password</label>
            <div class="col-sm-5">
                <input type="password" class="form-control" id="signup_password" placeholder="Password" name="password" />
            </div>
            <div class="col-sm-5">
                <input type="password" class="form-control" id="confirm_password" placeholder="Confirm" name="confirm_password" />
            </div>
        </div>
        <div class="row" style="margin-bottom:10px;">
            <div class="col-sm-2"></div>
            <div class="col-sm-10">
                <script src='https://www.google.com/recaptcha/api.js'></script>
                <?php 
                    // Recaptcha 
                    require_once(dirname(__FILE__)."/include/recaptchalib.php");
                    $publickey = "6LcTBw8TAAAAAOriZNY3CS7nukStq1WbcGRmprRR"; // You got this from the signup page.
                    echo recaptcha_get_html($publickey);
                 ?>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-2"></div>
            <div class="col-sm-10">
                <input type="submit" class="btn btn-primary btn-sm" value="Signup">
            </div>
        </div>
    </form>
3
  • 2
    Check your input types. nickname is not a valid type. Commented Oct 18, 2015 at 19:28
  • you have some html error it should be like <input type="text" class="form-control" id="nickname" placeholder="Nickname" name="nickname" /> </div> Commented Oct 18, 2015 at 19:28
  • For a debug session, you can replace the form method with GET so that you can see visually what gets submitted exactly.. Commented Oct 18, 2015 at 19:32

1 Answer 1

1

Several things, your HTML is invalid (though I'm not sure it's breaking it) please use appropriate type values in your input fields. For name and nickname, the valid type value is "text", not "name" or "nickname" those belong as values of the name and id tags for those inputs.

Using isset will be true even if the variable is an empty string, because the $_POST variable will have that variable, just probably empty so isset passes, you want to check for an empty string I think (use empty() for that)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.