Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ExeOutput for PHP: MySQL sample using the WAMP package Server2Go
- // By default, Server2go comes with a sample database. Root admin is not password-protected.
- $mysqlusername = "root";
- $mysqlpass = "";
- // Do not modify the following lines
- $mysqlport = getenv('S2G_MYSQL_PORT');
- $mysqlhost = "localhost:".$mysqlport;
- // We verify that our ExeOutput application was started by Server2go, otherwise, the MySQL server may not have started.
- if (empty($mysqlport)) die("This application cannot be started directly. Programmers: please use the Server2go EXE file, it will start this application automatically.");
- ?>
- <?php
- function db_connect()
- {
- $host = "localhost";
- $user = "root";
- $password = "";
- $database = "csv_db";
- $conn = mysqli_connect($host, $user, $password, $database);
- if ($conn == FALSE)
- {
- echo "Error: Unable to connect to the database!";
- return NULL;
- }
- return $conn;
- }
- function db_disconnect($conn)
- {
- mysqli_close($conn);
- return;
- }
- function checkUserAccessCookie()
- {
- /* Check if the user has the "userAccess" cookie (set during login) */
- if (isset($_COOKIE["userAccess"]))
- {
- return true;
- }
- return false;
- }
- function getDefaultUserFromCookie()
- {
- /* If the user has been here before, then a cookie named "userLogin"
- * with the user's username will be available. */
- if (isset($_COOKIE["userLogin"]))
- {
- return $_COOKIE["userLogin"];
- }
- /* If the cookie does not exist, then return blank instead */
- return "";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement