h.man96
h.man96

Reputation: 21

_POST not grabbing data

I am working on a login system and I am having issues with a post forum. Here is what I have I feel like I have tried almost everything with no luck.

I have tried renaming the names, and echo out info. The username works just fine it is the hiddenPass I am having trouble with.

    <script>
        function changeFormLogin() {
            var pass = document.getElementById('getPass').value;
            var username  = document.getElementById('username').value;
            var getSalt = <?php echo $salt ?>;
            var hashpass = sha256(getSalt+pass);

            document.getElementById("hiddenPass").value = hashpass;
            document.getElementById("hiddensalt").value = getSalt;
        }     
    </script>

    <h2>Sign Up Here</h2>
    <form onsubmit="changeFormLogin()" action="tryLogin.php" METHOD="POST">
        <p>Email</p>
        <input id="username" type="email" name="username" placeholder="Enter Email" value = "<?php echo $username ?>" required>
        <p>Password</p>
        <input id="getPass" type="password" name="password" placeholder="••••••" required>
        <!-- Add two hidden fields right here -->
        <input id="hiddenPass" type="hidden" name="hiddenPass1" value="">
        <input id="hiddensalt" type="hidden" name="hiddensalt" value="">
        <input type="submit" name="login" value="Sign In">
    </form>

Here is the PHP file:

   <?php
   include_once('connect.php');


   $username = $_POST['username'];
   $password = $_POST['hiddenPass1'];  
   $salt = $_POST['hiddensalt'];
   $userid = "";
   $valid = "";

Upvotes: 0

Views: 53

Answers (1)

Julio
Julio

Reputation: 11

you are missing send the form in the changeFormLogin function in order to submit the form, don't forget add id to your form

document.getElementById("yourFormId").submit();

Upvotes: 1

Related Questions