Extract HTML from Qbe::_getInsDelAndOrCell method
[phpmyadmin.git] / examples / signon.php
blob7c7c584724ff958f2b51ba9e9bff34157653f409
1 <?php
2 /**
3 * Single signon for phpMyAdmin
5 * This is just example how to use session based single signon with
6 * phpMyAdmin, it is not intended to be perfect code and look, only
7 * shows how you can integrate this functionality in your application.
8 */
9 declare(strict_types=1);
11 /* Use cookies for session */
12 ini_set('session.use_cookies', 'true');
13 /* Change this to true if using phpMyAdmin over https */
14 $secure_cookie = false;
15 /* Need to have cookie visible from parent directory */
16 session_set_cookie_params(0, '/', '', $secure_cookie, true);
17 /* Create signon session */
18 $session_name = 'SignonSession';
19 session_name($session_name);
20 // Uncomment and change the following line to match your $cfg['SessionSavePath']
21 //session_save_path('/foobar');
22 @session_start();
24 /* Was data posted? */
25 if (isset($_POST['user'])) {
26 /* Store there credentials */
27 $_SESSION['PMA_single_signon_user'] = $_POST['user'];
28 $_SESSION['PMA_single_signon_password'] = $_POST['password'];
29 $_SESSION['PMA_single_signon_host'] = $_POST['host'];
30 $_SESSION['PMA_single_signon_port'] = $_POST['port'];
31 /* Update another field of server configuration */
32 $_SESSION['PMA_single_signon_cfgupdate'] = ['verbose' => 'Signon test'];
33 $id = session_id();
34 /* Close that session */
35 @session_write_close();
36 /* Redirect to phpMyAdmin (should use absolute URL here!) */
37 header('Location: ../index.php');
38 } else {
39 /* Show simple form */
40 header('Content-Type: text/html; charset=utf-8');
41 echo '<?xml version="1.0" encoding="utf-8"?>' , "\n";
43 <!DOCTYPE HTML>
44 <html lang="en" dir="ltr">
45 <head>
46 <link rel="icon" href="../favicon.ico" type="image/x-icon">
47 <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
48 <meta charset="utf-8">
49 <title>phpMyAdmin single signon example</title>
50 </head>
51 <body>
52 <?php
53 if (isset($_SESSION['PMA_single_signon_error_message'])) {
54 echo '<p class="error">';
55 echo $_SESSION['PMA_single_signon_error_message'];
56 echo '</p>';
59 <form action="signon.php" method="post">
60 Username: <input type="text" name="user" autocomplete="username"><br>
61 Password: <input type="password" name="password" autocomplete="current-password"><br>
62 Host: (will use the one from config.inc.php by default)
63 <input type="text" name="host"><br>
64 Port: (will use the one from config.inc.php by default)
65 <input type="text" name="port"><br>
66 <input type="submit">
67 </form>
68 </body>
69 </html>
70 <?php