I take the column number, then password_hash($number). I want the PW in the same row, but it goes to the bottom.
I can export it as csv, put them in the right place, but that is not ideal.
I tried WHERE id = $id
Maybe I should use UPDATE ??
How to make the PW go in the current row in the column ‘password’?
<?php
$user = 'myusername';
$pass = 'mypassword';
try {
$dbh = new PDO('mysql:host=localhost;dbname=allstudentsdb', $user, $pass);
foreach($dbh->query('SELECT * from makePW1') as $row) {
$id = $row['id'];
print_r('ID is ' . $id . '<br>');
$number = $row['number'];
print_r('number is ' . $number . '<br>');
$password = password_hash($number, PASSWORD_DEFAULT);
print_r('password is ' . $password . '<br>');
$stmt = $dbh->prepare('INSERT INTO makePW1 (number, password) VALUES (:number, :password)' );
$stmt->execute(['number' => $number, 'password' => $password]);
}
$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
Ideally, each student would register himself or herself. I have a register, login system working great on my laptop, but when I upload it to my cheap’n’nasty GoDaddy shared hosting, it takes a really long time to load and often just will not finish! Don’t know why!