Advertisement
Guest User

Untitled

a guest
May 9th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. //Assign form properties to variables
  3. $first_name = $_POST["first_name"];
  4. $xp = $_POST["xp"];
  5. $date = $_POST["date"];
  6. //Connect to the mysql database.
  7. $mysql_username="usher_signup";
  8. $mysql_password="abc123";
  9. $link = mysql_connect('localhost', $mysql_username, $mysql_password);
  10. if (!$link) {
  11.     die('Could not connect: ' . mysql_error());
  12. }
  13. echo 'Connected successfully to MySQL<br>';
  14. //select the database
  15. mysql_select_db("signup", $link);
  16. //check to see if table exsists
  17. $table_name = $date;
  18. $sql = "SELECT * FROM $table_name";
  19. $result = @mysql_query($sql);
  20. if(!$result) {
  21. echo "No table exsists<br>";
  22. //create a new table
  23. $sql = "CREATE TABLE $table_name
  24. (
  25. FullName varchar(100),
  26. Experience varchar(100)
  27. )";
  28. mysql_query($sql,$link);
  29. echo "Mysql table created...<br/>";
  30. echo "Updating the info<br />";
  31.   //write to table the values of the variables from the form on index.php
  32.   $sql = "INSERT INTO $table_name (FullName, Experience) VALUES ('$first_name', '$xp')";
  33.   $result = @mysql_query($sql, $link);
  34.   //If check
  35.     if(!$result){
  36.       echo "Can Not Insert into Table";
  37.     }
  38.     else {
  39.       echo "Wrote to table.";
  40.     }
  41. }
  42. else {
  43. //table is exsistant
  44. echo "MYSQL table exsists<br />";
  45.   //write to table the values of the variables from the form on index.php
  46.   $sql = "INSERT INTO $table_name (FullName, Experience) VALUES ('$first_name', '$xp')";
  47.   $result = @mysql_query($sql, $link);
  48.   //If check
  49.     if(!$result){
  50.       echo "Can Not Insert into Table";
  51.     }
  52.     else {
  53.       echo "Wrote to table.";
  54.     }
  55. }
  56. //check to see if table exsists
  57.  
  58. ?>
  59. <html>
  60. <head>
  61. <title>
  62. LACLT - Usher Sign Up Sheet V2
  63. </title>
  64. <link rel="stylesheet" type="text/css" href="style.css">
  65. </head>
  66. <body>
  67. <br />
  68. <a href="index.php">Go Back</a>
  69. <br /><br />
  70.  
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement