Ég gerði síðu en svo var einhver villa ég get ekki fundið þessa villu(þegar ég reyni að hlaða inn síðunni kemur eitthvað um villu í línu 25). Er einhver hérna sem getur fundið villuna?
P.S. Þegar ég bjó til töfluna í mysql notaði eg md5() fallið fyrir passwordið.
Hér er kóðinn:
<?
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
$user;
$auth = FALSE;
$admin = FALSE;
session_start();
switch($_REQUEST['action']){
case "login":
$user = $_POST['username'];
$pass = md5($_POST['pass']);
$ip = md5($_SERVER['REMOTE_ADDR']);
mysql_connect(localhost,"username","password");
@mysql_select_db("database") or die( "Unable to select database");
$query="SELECT * FROM user WHERE username = ‘$user’;
$result=mysql_query($query);
$numrows = mysql_rumrows($result);
mysql_close();
if($numrows == 0){
$auth = FALSE;
$_SESSION = array();
session_destroy();
break;
}
if(mysql_result($result,0,"password") != $pass)
break;
$_SESSION['ip'] = $ip;
$_SESSION['user'] = $user;
if(mysql_result($result,0,"admin") == 1){
$_SESSION['admin'] = TRUE;
$admin = TRUE;
break;
}
$admin = FALSE;
break;
case "logout":
$auth = FALSE;
$_SESSION = array();
session_destroy();
break;
default:
if(isset($_SESSION['ip'])&&isset($_SESSION['admin'])){
if($_SESSION['ip'] == md5($_SERVER['REMOTE_ADDR'])){
$auth = TRUE;
if($_SESSION['admin'] == TRUE)
$admin=TRUE
}
else{
$_SESSION = array();
session_destroy();
}
}
}
if($auth = TRUE)
$user = $_SESSION['user'];
?>
<html>
<head>
<meta http-equiv="Content-Language" content="is">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>index</title>
<base target="_self">
</head>
<link rel="stylesheet" href="style.css" type="text/css">
<script>
var dayarray=new
Array("Sunnudagur","Mánudagur","Þriðjudagur","Miðvikudagur","Fimmtudagur","Föstudagur","Laugardagur")
var montharray=new
Array("Janúar","Febrúar","Mars","Apríl","Maí","Júní","Júlí","Ágúst","September","Oktober","Nóvember","Desember")
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
if (hours>12){
hours=hours-0
}
if (hours==0)
hours=00
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+",
"+daym+" "+montharray[month]+" , "+year+"
"+hours+":"+minutes+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforrit(){
if (document.all||document.getElementById)
getthedate()
setInterval("getthedate()",1000)
}
</script>
<body bgcolor="#000000" onLoad="goforrit()">
<div align="center">
<center>
<table border="1" cellspacing="0" width="802" id="AutoNumber1"
bordercolor="#0000FF" cellpadding="0" style="border-collapse: collapse"
bgcolor="#FFFFFF" height="223">
<tr>
<td colspan="2" width="800" height="200">
<img border="0" src="header.gif" width="800" height="200"></td>
</tr>
<tr>
<td height="22" valign="top" width="174" bgcolor="#FF0000"><b><div
align="left"><font face="verdana" size="1"><span
id="clock"></span></font></b></div></td>
<td rowspan="2" width="626" style="padding: 4" valign="top"
bgcolor="#000080"><?require($_GET['page'])?>&nbsp;</td>
</tr>
<tr>
<td width="174" height="100%" valign="top" bgcolor="#808080">
<p style="margin-top: 0; margin-bottom: 0">
<a title="Aðalsíða" href="index2.php?page=main.htm">Aðalsíða</a></p>
<p style="margin-top: 0; margin-bottom: 0">
<img border="0" src="d.gif" width="100%" height="1"></p>
<p style="margin-top: 0; margin-bottom: 0">
<a title="Um mig" href="index2.php?page=about.htm">Um mig</a></p>
<p style="margin-top: 0; margin-bottom: 0">
<img border="0" src="d.gif" height="1" width="100%"></p>
<?if($auth == FALSE){?>
<form method="POST" action='index2.php?page=<?echo "$_GET['page']"?>'>
<p style="margin-top: 0; margin-bottom: 0">
<font size="1"><b>Notandanafn:</b></font></p>
<p style="margin-top: 0; margin-bottom: 0">
<input type="text" name="username" size="13" maxlength="20"></p>
<p style="margin-top: 0; margin-bottom: 0"><font size="1"><b>
Lykilorð:</b></font></p>
<p style="margin-top: 0; margin-bottom: 0">
<input type="password" name="pass" size="13" maxlength="20"></p>
<p style="margin-top: 0; margin-bottom: 0">
<input type="submit" value="Skrá inn" name="B1"></p>
<input type="hidden" name="action" value="login">
</form>
<?}else{?>
<p align="center" style="margin-top: 0; margin-bottom: 0"><b>
<font face="Arial" size="1">Velkomin/n <?echo "$user"?></font></b></p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a title="Skrá út" href='index2.php?page=<?echo
"$_GET['page']"?>&action=logout'>
Smelltu hér til að skrá þig út</a></p>
<?}?>
</td>
</tr>
<tr>
<td colspan="2" width="800" bgcolor="#008080">
<p align="center">Alls hefur síðan fengið <?
mysql_connect(localhost,"usernam","password");
@mysql_select_db("database") or die( "Unable to select database");
$query="SELECT * FROM counter";
$result=mysql_query($query);
mysql_close();
$count = mysql_result($result,0,"count");
echo "$count";
?> heimsóknir.</td>
</tr>
</table>
</center>
</div>
</body>
</html>