Habs eh schon... Trotzdem
!
![danke](https://www.php-resource.de/forum/core/images/smilies/danke.gif)
$row = mysql_fetch_object($login_query);
if ($row = mysql_fetch_object($login_query)) {
$userid = $row->id;
} else {
$userid = null;
}
$row = mysql_fetch_object($login_query);
if(!empty($row['user_id'])) {
echo 'Hallo du .$row['user_id'];
}
else {
echo 'Zugangsdaten falsch!';
}
[COLOR=#000000][FONT=Courier New][COLOR=#0000cc]<?php[/COLOR][/FONT] [FONT=Courier New][COLOR=#000000]$username [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]$_POST[/COLOR][COLOR=#006600][[/COLOR][COLOR=#cc0000]'username'[/COLOR][/FONT][FONT=Courier New][COLOR=#006600]];[/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$password [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]$_POST[/COLOR][COLOR=#006600][[/COLOR][COLOR=#cc0000]'password'[/COLOR][/FONT][FONT=Courier New][COLOR=#006600]];[/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$session [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]session_id[/COLOR][/FONT][FONT=Courier New][COLOR=#006600]();[/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$connection [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]mysql_connect[/COLOR][COLOR=#006600]([/COLOR][COLOR=#cc0000]'localhost'[/COLOR][COLOR=#006600],[/COLOR][COLOR=#cc0000]'user'[/COLOR][COLOR=#006600],[/COLOR][COLOR=#cc0000]'geheim'[/COLOR][COLOR=#006600]) or die([/COLOR][COLOR=#cc0000]"Keine Verbindung zum Server."[/COLOR][/FONT][FONT=Courier New][COLOR=#006600]); [/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]mysql_select_db[/COLOR][COLOR=#006600]([/COLOR][COLOR=#cc0000]'datenbank'[/COLOR][COLOR=#006600]) or die([/COLOR][COLOR=#cc0000]"Keine Verbindung zur Datenbank."[/COLOR][/FONT][FONT=Courier New][COLOR=#006600]); [/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$pass [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]md5[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000cc]$password[/COLOR][/FONT][FONT=Courier New][COLOR=#006600]);[/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$user [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]$username[/COLOR][/FONT][FONT=Courier New][COLOR=#006600];[/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$login [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#cc0000]'SELECT id FROM members WHERE name="'[/COLOR][COLOR=#006600].[/COLOR][COLOR=#0000cc]$user[/COLOR][COLOR=#006600].[/COLOR][COLOR=#cc0000]'" AND pass="'[/COLOR][COLOR=#006600].[/COLOR][COLOR=#0000cc]$pass[/COLOR][COLOR=#006600].[/COLOR][COLOR=#cc0000]'" LIMIT 1';[/COLOR][/FONT][/COLOR] [COLOR=#000000][FONT=Courier New][COLOR=#0000cc]$login_query [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]mysql_query[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000cc]$login[/COLOR][COLOR=#006600]);[/COLOR][/FONT] [FONT=Courier New][COLOR=#006600]while([/COLOR][COLOR=#0000cc]$row [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]mysql_fetch_object[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000cc]$login_query[/COLOR][COLOR=#006600]))[/COLOR][/FONT][FONT=Courier New][COLOR=#006600] {[/COLOR][/FONT] [FONT=Courier New][COLOR=#0000cc]$userid [/COLOR][COLOR=#006600]= [/COLOR][COLOR=#0000cc]$row[/COLOR][COLOR=#006600]->[/COLOR][COLOR=#0000cc]id[/COLOR][/FONT][FONT=Courier New][COLOR=#006600];[/COLOR][/FONT] [FONT=Courier New][COLOR=#006600]}[/COLOR][/FONT] [FONT=Courier New][COLOR=#006600]echo [/COLOR][COLOR=#cc0000]'Willkommen User-Nummer '[/COLOR][/FONT][FONT=Courier New][COLOR=#006600];[/COLOR][/FONT] [FONT=Courier New][COLOR=#006600]echo [/COLOR][COLOR=#0000cc]$userid[/COLOR][/FONT][COLOR=#006600][FONT=Courier New];[/FONT][/COLOR] [FONT=Courier New][COLOR=#0000cc]?>[/COLOR][/FONT] [FONT=Courier New]<form action="login.php" method="post">[/FONT] [FONT=Courier New] Benutzername: <input type="text" name="username" /><br />[/FONT] [FONT=Courier New] Passwort: <input type="password" name="password" /><br />[/FONT] [FONT=Courier New] <input type="submit" name="submit" value="Einloggen" />[/FONT] [FONT=Courier New] </form>[/FONT][/COLOR]
$row = mysql_fetch_object($login_query);
$result = mysqli_query($this->db,$sql);
if (preg_match("/^(select|explain|show|describe)\s+/i", $sql) )
{
$this->num_rows = mysqli_num_rows($result);
}
elseif (preg_match("/^(insert|delete|update|replace)\s+/i", $sql) )
{
$this->rows_affected = mysqli_affected_rows($this->db);
}
if ($row = mysql_fetch_object($login_query)) {
$userid = $row->id;
} else {
$userid = null;
}
// var deklarieren und initalisieren
$userid = null;
if ($row = mysql_fetch_object($login_query))
$userid = $row->id;
Kommentar