I need to store some passwords in php mysql database. Problem is my password list have some escape characters. How can Save those records?
Below is the code, i am trying to add.
$pwd='\/'vm';
Insert into passwords(password) values ('$pwd') ;
Since this table deals with password, i dont have any other option other than storing the escape chrachets.
Thanks in advance!
Assuming the PDO extension and PHP 5.5+, arguably the best way to store passwords now would be something like:
//assuming you're retrieving the password from a user-POSTed form under SSL
$pwd = password_hash($_POST['pwd']);
//prepare the statement
$stmt = $pdo->prepare("INSERT INTO passwords (passwords.password) VALUES (:pwd)");
$stmt->bindParam(':pwd', $pwd, PDO::PARAM_STR);
//execute (returns boolean success state)
$success = $stmt->execute();
$pwd='\/'vm';
$pwd = mysqli_real_escape_string($pwd);
$query = "Insert into passwords(password) values ('$pwd')" ;
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.