Home > Mobile >  My POST form is not passing data I get no error message and I am just redirected to the next page wi
My POST form is not passing data I get no error message and I am just redirected to the next page wi

Time:04-30

I have a login form:

<!--SIGNUP = modal_form.php-->
<!--Modal start-->
<div  id="enroll" tabindex="-1" aria-labelledby="enrollLabel" aria-hidden="true">
    <div >
        <div >
            <div >
                <h5  id="enrollLabel">User signup</h5>
                <button type="button"  data-bs-dismiss="modal" aria-label="Close"></button>
            </div>

            <div >
                <p >Fill out this form we will get back to you</p>
                <!-- Form -->
                <form id="signup-form"  method="POST" action="./includes/signup.inc.php">
                    <?php
                    $fullUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";


                    if (strpos($fullUrl, "error=empty_input") == true) {
                        echo "<div class='alert alert-danger alert-dismissible fade show' role='alert'>
                        <strong>Holy guacamole!</strong> You should fill in on some of those fields below.
                        <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button>
                    </div>";
.
.
.
.
.
                   
                        <strong>Success!</strong> Success you signed up.
                        <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button>
                    </div>";
                    } else {
                        unset($_SESSION['error1']);
                    }
                    ?>

                    <div >
                        <label for="full-name">Full name\User name</label><br>
                        <p>*You can only have on user name per e-mail account</p>
                        <input type="text"  id="full-name" name="full-name"
                               placeholder="John Smith">
                        <small  id="message-full-name"></small>
                        <br>
                    </div>
                    <div >
                        <label for="email">Email</label>
                        <input type="email"  id="email" name="email"
                               placeholder="[email protected]">
                        <small  id="message-email"></small>
                        <br>
                    </div>

                    <div >
                        <label for="password">Password</label>
                        <input type="password"  id="password" name="password"
                               placeholder="Password">
                        <small  id="message-password"></small>
                        <br>
                    </div>

                    <div >
                        <label for="pwdRepeat">Password repeat</label>
                        <input type="password"  id="pwdRepeat" name="pwdRepeat"
                               placeholder="Retype Password">
                        <small  id="message-pwdRepeat"></small>
                        <br>
                    </div>

                    <a href="./includes/reset-password-form.php">Forgot your password?</a>

                    <div >
                        <button type="reset"  data-bs-dismiss="modal">Close</button>
                        <button type="submit" id="login-submit"  name="submit">Register now</button>
                    </div>

                    <script src="./js/signup_error_handler.js"></script>

                </form>
            </div>
        </div>
    </div>
</div>


For some reason it doesn't send any data to the page login.inc.php it opens that page and doesn't do anything. When i var_dump() POST it shows array() if I do the same to the input fields as in I the POST values I get null eventhough the form was filled with some value.

And this is the page to which the data is sent to:

<?php

if (isset($_POST['login-submit'])) {
    //Uzimamo podatke
    $email = $_POST["login-email"];
    $password = $_POST["login-password"];

    //Instanciranje klase SignupContr
    include "../classes/dbh.classes.php";
    include "../classes/login.classes.php";
    include "../classes/login-contr.classes.php";

    $signup = new LoginContr($email, $password);

    //Running error handlers and using signup

    $signup->loginUser();

    //Povratak na glavnu stranu

    header("location: ../index.php?error=none");
}

The $signup variable is the class which has all of the functions which check the input values on the servers side and if somehow the input values where empty then the user would get a message that the inputed values are empty however this message doesn't appear. When i click the login-submit button I am taken to the empty login.inc.php page and nothing happens.

CodePudding user response:

Simply, I can't find anything with login-submit as a name property. Maybe check if isset($_POST["password"]) or "email" or anything that is IN your form.

Because no login-submit is in your form, the if condition is never met.

name property is the thing that gets sent over not id. I see the issue you made. You need to remove the prefix: login- from the $_POST methods. Your name properties are only: password, email, submit, etc.

  • Related