<html>
<head>
<title>Week #14 Basic ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<body>


<?php

$db 
'scriptskewl';
$user 'hotestimscript';
$pw '9xkpzrzw';
$mysql_access mysql_connect("localhost" $user $pw);

if(!
$mysql_access){
    print(
"No connection<br /><br />");
} else {
    print(
"Connected to database...<br /><br />");
}


if(isset(
$_POST['submitButton'])){
    if(
$_POST['tableName'] == ''){ // make sure form is filled out
        
print("<br />Please enter a table name<br />");
    } else {
         
mysql_select_db($db$mysql_access);
        
$query "
        CREATE TABLE  $_POST[tableName](
        ID INT NOT NULL AUTO_INCREMENT,
        name VARCHAR(20) NOT NULL,
        password VARCHAR(20) NOT NULL,
        ip_address CHAR(15) NOT NULL,
        time_of_entry VARCHAR(24) NOT NULL,
        PRIMARY KEY (ID)
        )"
;
        
        if(!
mysql_query($query$mysql_access)){
            print(
"<br /><b>problem writing table</b><br />");
        }
    }
}
?>



<form method="POST" action="wk14basic.php">
<input type="text" name="tableName" />
<input type="submit" name="submitButton" value="Create Table">
</form>


<br /><br />
Here is a list of tables in the database:<br />
<?php
$result 
mysql_query("SHOW TABLES FROM $db"$mysql_access);
while(
$row mysql_fetch_row($result)){
    print(
"$row[0]<br />");
}
?>








<!-------------  END  ------------->


<br /><a href='../index.html'>Index</a><br />
<iframe src='wk14basicsrc.php' width='100%' height='210' style="margin:0;"></iframe>
<a href='../index.html'>Index</a>

</body>
</html>