Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Some PHP trouble. Im pretty lost on this one. It asks for a file that is on a di

ID: 3767557 • Letter: S

Question

Some PHP trouble. Im pretty lost on this one. It asks for a file that is on a disc but none came with the book.The book itself is full of errors. I just need help with the PHP Thanks for your time.

Write a PHP program that will ask for a users name and password. The program will generate a MD5 encrypted password. Store the username and the new password in a file called db.passwords.

Now create a PHP program that will ask for the username and pawword and admit the user only if his username and password match. If they do show the contents of the databook file.

Explanation / Answer

include("connect.php"); session_start(); if ($_SERVER["REQUEST_METHOD"] == "POST") { // Username and password sent from form in HTML $myusername = $_POST['username']; $mypassword = $_POST['password']; $sql = "SELECT id FROM users WHERE username='$myusername' and password='$mypassword'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $active = $row['active']; $count = mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if ($count == 1) { session_register("myusername"); $_SESSION['login_user'] = $myusername; header("location: welcome.php"); } else { $error = "Your username or password is invalid"; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote