Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Assign form properties to variables
- $first_name = $_POST["first_name"];
- $xp = $_POST["xp"];
- $date = $_POST["date"];
- //Connect to the mysql database.
- $mysql_username="usher_signup";
- $mysql_password="abc123";
- $link = mysql_connect('localhost', $mysql_username, $mysql_password);
- if (!$link) {
- die('Could not connect: ' . mysql_error());
- }
- echo 'Connected successfully to MySQL<br>';
- //select the database
- mysql_select_db("signup", $link);
- //check to see if table exsists
- $table_name = $date;
- $sql = "SELECT * FROM $table_name";
- $result = @mysql_query($sql);
- if(!$result) {
- echo "No table exsists<br>";
- //create a new table
- $sql = "CREATE TABLE $table_name
- (
- FullName varchar(100),
- Experience varchar(100)
- )";
- mysql_query($sql,$link);
- echo "Mysql table created...<br/>";
- echo "Updating the info<br />";
- //write to table the values of the variables from the form on index.php
- $sql = "INSERT INTO $table_name (FullName, Experience) VALUES ('$first_name', '$xp')";
- $result = @mysql_query($sql, $link);
- //If check
- if(!$result){
- echo "Can Not Insert into Table";
- }
- else {
- echo "Wrote to table.";
- }
- }
- else {
- //table is exsistant
- echo "MYSQL table exsists<br />";
- //write to table the values of the variables from the form on index.php
- $sql = "INSERT INTO $table_name (FullName, Experience) VALUES ('$first_name', '$xp')";
- $result = @mysql_query($sql, $link);
- //If check
- if(!$result){
- echo "Can Not Insert into Table";
- }
- else {
- echo "Wrote to table.";
- }
- }
- //check to see if table exsists
- ?>
- <html>
- <head>
- <title>
- LACLT - Usher Sign Up Sheet V2
- </title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <br />
- <a href="index.php">Go Back</a>
- <br /><br />
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement