Jump to content

Tom8001

Members
  • Posts

    205
  • Joined

  • Last visited

About Tom8001

  • Birthday 05/25/2000

Profile Information

  • Gender
    Male
  • Location
    Unk0wn

Tom8001's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, how would i code a script that finds certain words or characters in a thread on my forum and then redirect the user? Thanks!
  2. I dont understand how i can get rid of the vulnerability in the url you can change the username and token and take over accounts with my current code i don't understand how i can prevent this
  3. Thanks, the password is able to be reset now, but i have a field in the database called 'hash' and i have the query to update it with the hashed token but it does not change, Here is my new updated code: <?php require('./includes/connect.php'); $encodedToken = $_GET['token']; $token = hex2bin($encodedToken); $tokenHash = hash('sha256', $rawToken); $username = $_GET['s']; $stmt = $handler->prepare("UPDATE users SET hash = :hash WHERE username = :u"); $stmt->bindParam(':u', $username, PDO::PARAM_STR, 255); $stmt->bindParam(':hash', $tokenHash, PDO::PARAM_STR, 255); $stmt->execute(); if($stmt) { echo ' <form action="" method="POST"> <h3>New Password: </h3> <input type="password" name="newpass" placeholder="New Password" required /><br> <h3>Confirm Password: </h3> <input type="password" name="confpass" placeholder="Confirm Password" required /><br> <input type="submit" name="update" value="Update Password"> </form> '; } else { echo "Invalid token"; exit; } if($_POST['update']) { $newpass = $_POST['newpass']; $confpass = $_POST['confpass']; if($confpass == $newpass) { $enc_password = password_hash($confpass, PASSWORD_BCRYPT); $stmt = $handler->prepare("UPDATE users SET password = :cpass WHERE username = :u"); $stmt->bindParam(':u', $username, PDO::PARAM_STR, 255); $stmt->bindParam(':cpass', $enc_password, PDO::PARAM_STR, 255); $stmt->execute(); if($stmt) { echo "Your password has been reset!"; echo '<meta http-equiv="refresh" content="0;login.php">'; } else { echo "Error"; exit; } } } ?>
  4. I don't see what you mean about not inserting the token hash in the query string?
  5. $encodedToken = $_GET['token']; $token = hex2bin($encodedToken); $tokenHash = hash('sha256', $token); $username = $_GET['s']; $stmt = $handler->prepare("UPDATE users SET reset = ".$tokenHash." WHERE username = :u"); $stmt->bindParam(':u', $username, PDO::PARAM_STR, 255); $stmt->execute(); Fatal error: Call to a member function prepare() on a non-object I get this error when clicking the reset link in the email, it says on line 10 which is the update query
  6. I read it on a stack overflow thread somewhere, And i don't know the token is what doesn't make sense to me.
  7. Hi, This is my forgot password code so far. <?php require('./includes/connect.php'); error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', 1); if($_SERVER['REQUEST_METHOD'] == "POST") { $email = $_POST['email']; $email = htmlentities($email, ENT_QUOTES); $stmt = $handler->prepare("SELECT email FROM users WHERE email = :email"); $stmt->bindParam(':email', $email, PDO::PARAM_STR, 255); $stmt->execute(); if($stmt) { $fetch = $stmt->fetch(); if($email == $fetch['email']) { $stmt = $handler->prepare("SELECT username FROM users WHERE email = :email"); $stmt->bindParam(':email', $email, PDO::PARAM_STR, 255); $stmt->execute(); $row = $stmt->fetch(); $username = $row['username']; $token = mcrypt_create_iv(MCRYPT_RAND); $headers = "Password Reset"; $body = "Hi, ".$username."!, You have recently requested to reset your password. ".PHP_EOL." \n If you did not make this request please forget this email. ".PHP_EOL." To reset your password please click this link: <a href='http://ps3modding.co.uk/forgot_password.php?token=$token'></a>"; } else { echo "The E-Mail Address entered was Not Found."; } } } ?> What i am wondering is because your not ment to store the token in the database how do you check to see if it is valid? Is it done by $_COOKIE?, Thanks
  8. Sorry i'm still fairly new to PHP i don't understand what to do about the token am i ment to use the rand() function?
  9. What i don't understand is when they request to reset their password, I will be hashing the password using password_hash but how am i ment to let them see the password in the email in plaint text? Edit: Sorry we posted at the same time
  10. I was thinking to just reset the password when the form is submitted and then query the database for the new password, decrypt it and send it via email?
  11. I am currently using password_hash and password_verify in my code, I am unsure can i decrypt the password?
  12. Thanks, I will take a look at other threads.
  13. Hi, how can i create a Forgotten password script? I know security can be a real issue with this if the code isn't written correctly.
  14. Thanks, yeah i got confused with the query's , Thanks everyone for the help it's much appreciated.
  15. Thanks, I'm not getting errors now but it says the old password is incorrect function chgPwd() { require('connect.php'); $username = $_SESSION['username']; $password = $_POST['password']; $npassword = $_POST['npassword']; $cpassword = $_POST['cpassword']; $sql = $handler->prepare("SELECT password FROM users WHERE password = :p"); $sql->bindParam(':p', $password, PDO::PARAM_STR, 255); $sql->execute(); $fetch = $sql->fetch(); if($cpassword !== $cpassword) { echo "Passwords do not match!"; } if(password_verify($password, $fetch['password'])) { $pass_isok = 1; } else { $pass_isok = 0; } if($pass_isok == 1) { $enc_password = password_hash($cpassword, PASSWORD_BCRYPT); $sql = "UPDATE users SET password = '$enc_password' WHERE username = '$username'"; $sql->execute(); if($sql >= 1) { echo "Password updated successfully!"; } else { echo "Error. Password could not be updated at this time, If this persists please contact support."; } } else { echo "Your old password is incorrect!"; } } That's the code updated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.