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 = "";
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.