Jeg har et mindre problem.
Jeg har et mini forum, hvor hver gang man klikker på et link og den skal vise en bruger, så "logger den ind" som den bruger, i stedet for bare at nøjes at vise brugerens profil.
Her er lidt kode:
Login'et:
<?php
session_start();
if($logud=="true"){
header("Location:logud.php?logud=true");
}
if(isset($Nickname) AND isset($Password)){
$conn = mysql_connect("localhost", "", "") or die (mysql_error());
mysql_select_db("", $conn) or die (mysql_error());
$sql = "select * FROM chat_user WHERE Nick = '$Nickname' AND Password = '$Password'";
$result = mysql_query($sql, $conn) or die (mysql_error());
$newArray = mysql_fetch_array($result);
if($newArray['Id']!=""){
$_SESSION['login']=true;
$_SESSION['Id']=$newArray['Id'];
$_SESSION['LIMIT']=$newArray['Antal_linjer'];
$_SESSION['Nick']=$newArray['Nick'];
$_SESSION['LoginTime']=date("YmdHis");
$sql = mysql_query("INSERT INTO chat_main_chat(User, Tid, Text) values('0', '". date("YmdHis") ."', '$Nickname logger ind')",$conn) or die (mysql_error());
$sql = mysql_query("UPDATE chat_user SET Online='1' WHERE Id='". $_SESSION['Id']."' ",$conn) or die (mysql_error());
$sql = mysql_query("UPDATE chat_user SET Point='+1' WHERE Id='". $_SESSION['Id']."' ",$conn) or die (mysql_error());
$sql = mysql_query("INSERT INTO ip(Id, Date, Ip) values('". $_SESSION['Id']."', '". date("Y-m-d G:i:s") ."', '". $_SERVER['REMOTE_ADDR'] ."')",$conn) or die (mysql_error());
header("Location:index.php");
} else {
print "Fejl i login";
}
}
if($_SESSION['login']==true){
?>
<html>
<head>
<meta name="keywords" content="Chat, fora, forum">
<meta http-equiv="pragma" content="nocache">
<meta http-equiv='case-control' content='no-store'>
<meta http-equiv='imagetoolbar' content='no'>
<meta http-equiv='imagetoolbar' content='false'>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function logud(){
chatluk = window.open('logud.php?logud=true','mywin2','left=-100,top=-100,width=1,height=1,toolbar=0,resizable=0');
}
</script>
</head>
<body>
<?
if (!$show){ $show = "forside"; }
$showsite = "chat/" . $show . ".php";
if (!file_exists($showsite)){$showsite = "404.php";}
?>
<HTML>
<HEAD>
<TITLE>Chat</TITLE>
<STYLE>
body, td {
font-family: verdana, tahoma, arial;
font-size: 11px;
}
a:link, a:visited {
color: #205080;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #5080A0;
}
</STYLE>
</HEAD>
<body bgcolor="#B0B0B0">
<CENTER>
<TABLE CELLSPACING=12 CELLPADDING=0 WIDTH=100% HEIGHT=100%>
<TR>
<TD COLSPAN=3 STYLE="height: 50; border: 1px solid #AFAFAF;">
<a href="javascript:logud();">Logud</a> || Du er nu logget ind som: <?=$_SESSION['Nick']?></a> || <a href="?show=profil">Profil</a> || <A HREF="?show=tagwall">GB</A>
<form action="" method="get">
<select name="show">
<OPTGROUP label="Rediger">
<option value="ret/ret_profil">Profil</option>
<option value="ret/ret_profil_text">Profil Text</option>
<option value="ret/ret_dagbog">Dagbog</option>
<option value="ret/ret_digte">Digte/Sange</option>
<option value="ret/ret_jokes">Jokes</option>
<option value="ret/ret_profil_billede">Profil Billede</option>
<OPTGROUP label="Indstilninger">
<option value="ind_dagbog">Dagbog</option>
<option value="ind_profil">Profil</option>
<OPTGROUP label="Se">
<option value="profil">Profil</option>
<option value="tagwall">Gæstebogen</option>
<option value="dagbog">Dagbog</option>
<option value="digte">Digte/Sange</option>
<option value="chat">Chat</option>
<option value="online">Online Brugere</option>
<option value="offline">Offline Brugere</option>
<option value="jokes">Jokes</option>
<?
$conn = mysql_connect("localhost", "pro_jekt_dk", "aksel17") or die (mysql_error());
mysql_select_db("pro_jekt_dk", $conn) or die (mysql_error());
$sql = "SELECT * FROM chat_user WHERE Id='". $Id ."'";
$result = mysql_query($sql, $conn) or die (mysql_error());
$newArray = mysql_fetch_array($result);
if($newArray['Status']==Admin){
print '<OPTGROUP label="Administrator Rettigheder">';
print '<option value="admin/news">Tilføj Nyhed</option>';
print '<option value="admin/ip">Vis brugernes IP</option>';
}
?>
</select>
<input type="submit" value="Hent">
</form>
</TD>
</TR>
<TR>
<TD width="15%" VALIGN=TOP STYLE="border: 1px solid #AFAFAF; padding: 20;">
<A HREF="?show=<?=$show?>">Opdater Siden</A> <br>
<br>
<A HREF="?show=forside">Forsiden</A> <br>
<A HREF="?show=chat">Chat</A> <br>
<A HREF="?show=artikler">Artikler</A> <br>
<br>
<A HREF="?show=online">Online</A> <br>
<A HREF="?show=offline">Offline</A> <br>
<A HREF="?show=soeg">Søg Bruger</A> <br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<form action="" method="get">
<select name="show">
<option value="status/online">Online</option>
<option value="status/busy">Optaget</option>
<option value="status/brb">Straks tilbage</option>
<option value="status/away">Ikke til stede</option>
<option value="status/eat">Spiser</option>
<option value="status/offline">Vis som Offline</option>
</select>
<br>
<input type="submit" value="Status">
</form>
</TD>
<TD width="85%" VALIGN=TOP STYLE="border: 1px solid #AFAFAF; padding: 20;">
<div align=justify>
<?
include $showsite;
?>
</div>
</TD>
</TR>
<TR>
<TD COLSPAN=3 STYLE="height: 30; border: 1px solid #AFAFAF;" ALIGN=CENTER>
<script language="JavaScript">
function klokken() {
tid = new Date;
H = tid.getHours();
if (H < 10) {H = "0" + H;} else H = H;
i = tid.getMinutes();
if (i < 10) {i = "0" + i;} else i = i;
s = tid.getSeconds();
if (s < 10) {s = "0" + s;} else s = s;
Y = tid.getYear();
tiden.innerHTML = H + ":" + i + ":" + s + "";
setTimeout ("klokken()" , 1000);
}
</script>
Klokken er:
<body onLoad="klokken();">
<span id="tiden"></span>
--- Dags Dato
<? echo $dato = date("d/m-Y");
?><BR>
Copyright © 2006 Danni Hansen, i Sammenarbejde med Ken Kino
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<?
} else {
?>
<table border="0" width="100%">
<tr>
<td width="20%"></td>
<td width="60%">
<center>
<A HREF="chat/make_user.php"TARGET="_BLANK">Opret Bruger</A> || <A HREF="chat/about.php"TARGET="_BLANK">About</A>
</center>
</td>
<td width="20%"></td>
</tr>
<tr>
<td width="20%"></td>
<td width="60%">
<center>
<form action="?" method="post">
Bruger navn:<br>
<input type="text" name="Nickname"><br>
Kodeord:<br>
<input type="password" name="Password"><br>
<input type="submit" value="Login">
</form>
</center>
</td>
<td width="20%"></td>
</tr>
<tr>
<td width="20%"></td>
<td width="60%"></td>
<td width="20%"></td>
</tr>
</table>
<?
}
?>
Og vis bruger:
<?php
$Id = $_GET['USERID'];
$conn = mysql_connect("localhost", "", "") or die (mysql_error());
mysql_select_db("", $conn) or die (mysql_error());
$sql = "SELECT * FROM chat_user, postnr WHERE chat_user.Id='". $_GET['USERID'] ."' AND postnr.Postnr = chat_user.Post";
$result = mysql_query($sql, $conn) or die (mysql_error());
if($_GET['USERID']==""){
print "Brugeren existere ikke";
} else if ($newArray['Id']==""){
print "Brugeren existere ikke";
} else {
if($newArray['Online']==1){
print "<h3>Online</h3>";
} else if($newArray['Online']==2){
print "<h3>Optaget</h3>";
} else if($newArray['Online']==3){
print "<h3>Straks Tilbage</h3>";
} else if($newArray['Online']==4){
print "<h3>Ikke Til Stede</h3>";
} else if($newArray['Online']==5){
print "<h3>Ude Og Spise</h3>";
} else if($newArray['Online']==0){
print "<h3>Offline</h3>";
} else {
print "<h3>Ukendt Status</h3>";
}
while ($newArray = mysql_fetch_array($result)){
print '<table border="0" width="100%">';
print ' <tr>';
print ' <td width="10%"><b>Nicknavn:</b></td>';
print ' <td width="10%">'. $newArray['Nick'] .'</td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"><b>Fornavn:</b></td>';
print ' <td width="10%">'. $newArray['Navn'] .'</td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"><b>Efternavn:</b></td>';
print ' <td width="10%">'. $newArray['Efternavn'] .'</td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"><b>Født:</b></td>';
print ' <td width="10%">'. $newArray['Dato'] .'</td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"><b>Oprettet:</b></td>';
print ' <td width="10%">'. $newArray['Date'] .'</td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"></td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"><b>Post nr. + By:</b></td>';
print ' <td width="10%">'. $newArray['Postnr'] .' '. $newArray['By'] .'</td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"></td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"><a href="?show=vis_galleri&Galleriid='. $USERID .'">Galleri</a></td>';
print ' <td width="10%"><a href="?show=vis_blog&Blogid='. $USERID .'">Dagbog/Blog</a></td>';
print ' <td width="10%"><a href="?show=vis_tid&Tidid='. $USERID .'">Tid</a></td>';
print ' </tr>';
print ' </table>';
print '<table border="0" width="100%">';
print ' <tr>';
print ' <td width="10%"></td>';
print ' <td width="80%"><center><b>Profil Text</b></center></td>';
print ' <td width="10%"></td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"></td>';
print ' <td width="80%">'. $newArray['Fri_text'] .'</td>';
print ' <td width="10%"></td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"></td>';
print ' <td width="10%"></td>';
print ' <td width="10%"></td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"></td>';
print ' <td width="10%"></td>';
print ' <td width="10%"></td>';
print ' </tr>';
print ' <tr>';
print ' <td width="10%"></td>';
print ' <td width="10%"><center><a href="?show=vis_tagwall&Tagwall='. $USERID .'">VIS GÆSTEBOGEN</a></center></td>';
print ' <td width="10%"></td>';
print ' </tr>';
print '</table>';
}
}
?>
Nogen der kan hjælpe?