Andreu | 0d72bd6 | 2019-09-17 23:31:14 +0200 | [diff] [blame^] | 1 | <html> |
| 2 | <head> |
| 3 | <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
| 4 | <?php |
| 5 | $servername = "fdb22.awardspace.net"; |
| 6 | $username = "3155560_users"; |
| 7 | $password = "btechnoro@fox4news.info"; |
| 8 | |
| 9 | // Create connection |
| 10 | $conn = new mysqli($servername, $username, $password, "3155560_users"); |
| 11 | if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); |
| 12 | $conn->set_charset("utf8"); |
| 13 | |
| 14 | $id = $_POST['user']; |
| 15 | $query = "SELECT * FROM users WHERE id=".$id; |
| 16 | |
| 17 | if ($result = $conn->query($query)) { |
| 18 | |
| 19 | while ($row = $result->fetch_row()) { |
| 20 | echo "<script>let db_info = {'id': ".$row[0]; |
| 21 | echo ", 'nom':'".$row[1]."', 'curs':".$row[2].", 'grau':".$row[3]; |
| 22 | echo ", 'quimata':".$row[4].", 'quielmata':".$row[5]; |
| 23 | echo "}; console.log(db_info);</script>"; |
| 24 | } |
| 25 | |
| 26 | $result->close(); |
| 27 | } else { |
| 28 | echo "Wrong query"; |
| 29 | } |
| 30 | |
| 31 | // Close connection |
| 32 | $conn->close(); |
| 33 | ?> |
| 34 | </head> |
| 35 | <body> |
| 36 | <?php |
| 37 | // Rebut l'SQL, l'enviem com a JSON a main.html |
| 38 | echo ' |
| 39 | <script> |
| 40 | let infoString = JSON.stringify(db_info); |
| 41 | let infoBase64 = btoa(infoString); |
| 42 | |
| 43 | window.location.href = "./main.html?info=" + infoBase64; |
| 44 | </script> |
| 45 | '; |
| 46 | ?> |
| 47 | </body> |
| 48 | </html> |