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