Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- $database = "";
- //Variables submitted by the users
- $email = $_GET["email"];
- $otp = $_GET["otp"];
- // Create connection
- $conn = new mysqli($servername, $username, $password, $database);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //check if user already verified
- $sql = "SELECT emailverified FROM users WHERE email = '" . $email . "'";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- if($row["emailverified"] == '1')
- {
- echo "verified already die();";
- die();
- }
- }
- }
- $sql = "SELECT otp FROM users WHERE email = '" . $email . "'";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $test02 = password_verify($row["otp"], $otp);
- if ($test02 == true)
- {
- $sql = "UPDATE users SET emailverified='1' WHERE email = '" . $email . "'";
- if ($conn->query($sql) === TRUE) {
- echo "Verification Sucess.";
- echo "<meta http-equiv=\"refresh\" content=\"0; URL=HIDDEN\" />";
- } else {
- echo "Verification Failed.";
- }
- die();
- }
- else
- {
- echo "Wrong, OTP";
- }
- }
- }
- $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement