Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. // ExeOutput for PHP: MySQL sample using the WAMP package Server2Go
  3.  
  4. // By default, Server2go comes with a sample database. Root admin is not password-protected.
  5. $mysqlusername = "root";
  6. $mysqlpass = "";
  7. // Do not modify the following lines
  8. $mysqlport = getenv('S2G_MYSQL_PORT');
  9. $mysqlhost = "localhost:".$mysqlport;
  10.  
  11. // We verify that our ExeOutput application was started by Server2go, otherwise, the MySQL server may not have started.
  12. if (empty($mysqlport)) die("This application cannot be started directly. Programmers: please use the Server2go EXE file, it will start this application automatically.");
  13.  
  14. ?>
  15.  
  16. <?php
  17.  
  18. function db_connect()
  19. {
  20. $host = "localhost";
  21. $user = "root";
  22. $password = "";
  23. $database = "csv_db";
  24.  
  25. $conn = mysqli_connect($host, $user, $password, $database);
  26.  
  27. if ($conn == FALSE)
  28. {
  29. echo "Error: Unable to connect to the database!";
  30. return NULL;
  31. }
  32.  
  33. return $conn;
  34. }
  35.  
  36.  
  37. function db_disconnect($conn)
  38. {
  39. mysqli_close($conn);
  40. return;
  41. }
  42.  
  43.  
  44. function checkUserAccessCookie()
  45. {
  46. /* Check if the user has the "userAccess" cookie (set during login) */
  47. if (isset($_COOKIE["userAccess"]))
  48. {
  49. return true;
  50. }
  51.  
  52. return false;
  53. }
  54.  
  55.  
  56. function getDefaultUserFromCookie()
  57. {
  58. /* If the user has been here before, then a cookie named "userLogin"
  59. * with the user's username will be available. */
  60. if (isset($_COOKIE["userLogin"]))
  61. {
  62. return $_COOKIE["userLogin"];
  63. }
  64.  
  65. /* If the cookie does not exist, then return blank instead */
  66. return "";
  67. }
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement