CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, userName VARCAR(20), firstName VARCHAR(40), lastName VARCHAR(40), password VARCHAR(40), accesTime DATE, balance FLOAT, ... ); DROP TABLE users;
INSERT INTO users (userName, password, balance) VALUES ("UserBob", "bobsPass", 0.0);
SELECT balance FROM users WHERE userName ="Bob" and password = "bobPass"; UPDATE users SET balance=0.0 WHERE userName = "Bob";
$conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, firstName, lastName FROM users"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstName"]. " " . $row["lastName"]. "
"; } } else { echo "0 results"; } $conn->close();
$input_uname = $_GET['firstName']; $input_pwd = $_GET['password']; $hashed_pwd = sha1($input_pwd); ... $sql = "SELECT id, firstName, balance, password FROM users WHERE firstName='$input_uname' and password='$hashed_pwd'"; $result = $conn -> query($sql);