create_table.php
and be sure it is saved in your lab7
folder.<? if($_GET['key']!="XXX") { die("Access denied"); } $mysqli = new mysqli("localhost", "sienasel_sbxusr", "Sandbox@)!&", "sienasel_sandbox"); $sql = "CREATE TABLE ????? ( username VARCHAR(64) NOT NULL, password VARCHAR(64) NULL, usertype VARCHAR(64) NOT NULL DEFAULT 'normal', games INT NOT NULL DEFAULT '0', points FLOAT NOT NULL DEFAULT '0.0', PRIMARY KEY (username) )"; $mysqli->query($sql); $mysqli->close(); ?>
http://s123456.sienasellbacks.com/lab7/create_table.php?key=XXX
show_columns.php
and be sure it is saved in your lab7
folder.<? $sql = "SHOW COLUMNS FROM ?????"; $mysqli = new mysqli("localhost", "sienasel_sbxusr", "Sandbox@)!&", "sienasel_sandbox"); $result = $mysqli->query($sql); $mysqli->close(); echo '<table>'; echo '<tr><th>field name</th><th>data type</th><th>null?</th><th>index</th><th>default value</th></tr>'; while ($row = $result->fetch_row()) { echo '<tr>'; foreach ($row as $value) { echo '<td>'.$value.'</td>'; } echo '</tr>'; } echo '</table>'; ?>
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/show_columns.php
add_users.php
and be sure it is saved in your lab7
folder.<? if($_GET['key']!="3587") { die("Access denied"); } $sql = "INSERT INTO ????? VALUES ('alice', '".'$2y$10$rGSvwmvurEuoNgei6WSCCOs9A/WvXx0mwGGYrXIEJV4zlQo8vmGTq'."', 'admin', '20', '1257'), ('bob', '".'$2y$10$HdGIIseolWHnE6/Zr5F8lOIAunKAvo.MXpXIxdLWuWHtTymDEPODW'."', 'normal', '15', '2165')"; $mysqli = new mysqli("localhost", "sienasel_sbxusr", "Sandbox@)!&", "sienasel_sandbox"); $mysqli->query($sql); $mysqli->close(); ?>
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/add_users.php?key=XXX
show_data.php
and be sure it is saved in your lab7
folder.<? $mysqli = new mysqli("localhost", "sienasel_sbxusr", "Sandbox@)!&", "sienasel_sandbox"); $result = $mysqli->query("SHOW COLUMNS FROM ?????"); echo '<table>'; echo '<tr>'; while ($row = $result->fetch_row()) { echo '<th>'.$row[0]."</th>"; } echo '</tr>'; $result->close(); $result = $mysqli->query("SELECT * FROM ?????"); while ($row = $result->fetch_row()) { echo '<tr>'; foreach ($row as $value) { echo '<td>'.$value.'</td>'; } echo '</tr>'; } echo '</table>'; $result->close(); $mysqli->close(); ?>
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/show_data.php
login.php
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/login.php
password_verify
function hashes the submitted password
before doing the comparison.
verify_login.php
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/verify_login.php
logout.php
and be sure it is saved in your lab7
folder.<? session_start(); session_destroy(); unset($_SESSION); die("Session Destroyed"); ?>
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/logout.php
header("Location: http://s123456.sienasellbacks.com/lab7/login.php");
where "s123456" is your userid.header
function should always be the 2nd to last line of code.
The last line should be the die
function.insert_user.php
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/insert_user.php
input type="text"
tags to the form$_POST
variable.delete_user.php
lab7
folder on the server.http://s123456.sienasellbacks.com/lab7/delete_user.php
select
and option
tags, so the username can be selected from a drop-down menu.
<input type="text" name="username">
tag with a block of PHP
code that will dynamically generate the HTML tags for a drop-down menu. SELECT username FROM ?????
)
to get all the usernames.show_data.php
as a model. Generating a drop-down menu is similar to
generating the column headers but instead of creating tr
and th
tags
you will generate select
and option
where $row[0]
is the inner value of the option
tag.name="username"
Combine all your scripts into a unified application.
Show your instructor that you can login and insert a new user where you can specify usertype, games and points. Use the show data functionality to demonstrate that the insert worked. Then, delete a user with the drop down menu. Again, use show data to demonstrate that the user was deleted. Finally, logout and show that all your scripts are protected.
Create a zip file of your lab7
folder called lab7.zip
and submit the file in Blackboard.
In the comment area of Blackboard put your partner's name.