Change to any database after login:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<?php $servername = "mysql"; $username = "xx"; $password = "xx"; //set content type to CSV (to be set here to be able to access this page also with a browser) header('Content-type: content="text/html; charset=utf8"'); $charset=mysqli_character_set_name($conn); echo "Default character set is: " . $charset; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Change character set to utf8 mysqli_set_charset($conn,"utf8"); // Change Time Zone date_default_timezone_set("Asia/Hong_Kong"); // Select database $dbname = $_GET['dbname']; mysqli_select_db($conn,"$dbname"); $FirstName = date("Y-m-d"); $LastName = date("h:i:sa"); $dayofweek = $_GET['Street']; $City = $_GET['City']; $State = $_GET['State']; $sql = "INSERT INTO absence (B,C,D,E,F) SELECT '$FirstName','$LastName',D,F,G from student WHERE (E LIKE '%$dayofweek%' AND K='active') OR (F LIKE '%$dayofweek%'AND K='active')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully".$dayofweek; } else { echo "Error: " . $sql . "<br>" . $conn->error; } ?> |