msql code looked weird

master
Jakob 2020-03-08 15:35:56 +01:00
parent 3b257dd416
commit a75fc950a5
1 changed files with 23 additions and 16 deletions

View File

@ -1,15 +1,22 @@
<?php <?php
%PLEAZE_NO_CACHE% %PLEAZE_NO_CACHE%
session_start(); session_start();
%SET_LOGIN_VARIABLE% %SET_LOGIN_VARIABLE%
//Todo: make this a setting for users that use VPNs/Proxies and seem to jump around the world rather quickly... //Todo: make this a setting for users that use VPNs/Proxies and seem to jump around the world rather quickly...
%NO_CHEAP_SESSION_STEALING% %NO_CHEAP_SESSION_STEALING%
$pdo = new PDO('mysql:host=localhost;dbname=web', 'webstuff', 'Schei// auf Pa$$w0rter!'); $pdo = new PDO('mysql:host=localhost;dbname=web', 'webstuff', 'Schei// auf Pa$$w0rter!');
$statement = $pdo->prepare('SELECT name FROM users WHERE id = :user_id;'); // to be replaced with optional user name off the user data table $error = false;
$result = $statement->execute(array('user_id' => $_SESSION['user_id'])); $error_message = "";
$dbentry = $statement->fetch(); if (!$error) {
$username = $dbentry['name']; $statement = $pdo->prepare("SELECT name FROM users WHERE id=:uid"); // to be replaced with optional user name off the user data table
$statement->execute(array("uid"=>$_SESSION[user_id]));
$dbentry = $statement->fetch();
$username = $dbentry[name];
}
if (!$result) {
$error_message = "Error: SQL error.\n" . $statement->queryString . "\n" . $statement->errorInfo()[2];
}
$navbar = "home"; $navbar = "home";
//ToDo: differentiate between home and userhome (or auto-redirect) //ToDo: differentiate between home and userhome (or auto-redirect)
@ -23,13 +30,13 @@ $navbar = "home";
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
%NAVBAR% %NAVBAR%
<div class="container"> <div class="container">
<div class="item-1"> <div class="item-1">
<center><h1>ThreadR</h1></center> <center><h1>ThreadR</h1></center>
</div>
<div class="item-2">
<center><h3><?php echo "Welcome back, $username !";?> </h3></center>
</div>
</div> </div>
<div class="item-2"> </html>
<center><h3><?php echo "Welcome back, $username !";?> </h3></center>
</div>
</div>
</html>