GSW Posted March 14, 2019 Share Posted March 14, 2019 Hello, I'm making a php script to reset AD account. The first form is for collect the users information, and send a mail if the user is locked. In the mail there is a random number ($test). A second form appears for enter the code ($code). If $code == $test then the AD Account get unlocked. The last one don't work, because $test is empty. What am I doing wrong? and if you can improve the script let me know. Best regards, GSW functions.php reset.php Link to comment Share on other sites More sharing options...
Mudsaf Posted April 2, 2019 Share Posted April 2, 2019 (edited) Have you checked if this returns the unid() value? echo "line 106  " . $test . "<br/>"; Just double check if everything goes through. Simplified your code for testing and worked for me. <?php function Send_mail($to){ return uniqid(); } $test = Send_mail("1"); if (isset($_POST['code']) && !empty($_POST['code'])){ $code = htmlspecialchars ($_POST['code']); } // I don't get echo good, because $test is empty. if (!empty($code)){ if ($code == $test){ echo "good"; } else{ echo "bad"; echo "<br>"; echo "line 149  " . $code; echo "<br>"; echo "line 151  " . $test; } } if (!empty($test)){ echo "line 156  " . $test; ?> <div class="code"> <form method="post"> Code: <input type="text" name="code"> <input type="submit"> </form> </div> <?php } //END for loop ?> Also noticed that what you're trying to do is not possible with method you're currently doing. Every time you do post/get action it will get new unique id and wont match the form code (unless you guess the uniqid). Instead store the uniqid to php session or database to make it work and simply remove it after. Edited April 2, 2019 by Mudsaf Link to comment Share on other sites More sharing options...
dsonesuk Posted April 2, 2019 Share Posted April 2, 2019 Non breaking space encoding finishes with semi-colon. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now