I stand in the position where i have made a website locally to be used as a product to a later presentation.
The website within keeps login, address book, message center and events.
My problem is should in my login script (Since, tilslut.php) suddenly stopped working 100%. It works in the sense where i will be logged in from index.php, with the username "Nicolaj" with the password "123789456", but it keeps reporting invalid username / password when it must be approved from next page, check.php, after which it should be send to the page, forside.php
If you start to try to jump from check.php when it reported errors and on to forside.php there is no problem, but if you log out on the page forside.php. Then you can't access any of the other pages.
Someone who can help me with what it is that creates the problem? :)
(The codes for the various pages are listed below.)
Index.php
<?php
session_start();
$_SESSION['loggedin'] = true;
?>
<html>
<style type="text/css">@import url(css.css);</style>
<script>
function msg()
{
alert("Kontakt din administrator på Nicolaj-Aaroe@live.dk!");
}
</script>
<center><br><br><br><br>
<title>Familielogin:: LOGIN</title>
<font size="200" color="navy">Familieside</font><br>
Velkommen til familielogin<br>
Log venligst ind!
<form action="check.php" method="post" name="login">
B: <input type="text" value="username" name="username"/><br>
K: <input type="password" value="password" name="password"/><br>
<input type="submit" name="login" value="Log ind"/></form>
<input type="button" name="glemt" value="Glemt Login" onclick="msg()"/>
</form>
</div>
</html>
Check.php
<?php
$_SESSION['errors']=0;
$_SESSION['loggedin'] = true;
include("config.php");
?>
<?php
if(isset($_POST['login']));
{
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1) {
$_SESSION['username'] = $_POST['username'];
header('Location: forside.php');
} else {
echo "<font color='red'><center><br><br><br><br>Forkert brugernavn eller password</font>";
} }
?>
<html>
<center><br><br><br><br>
<style type="text/css">@import url(css.css);</style>
<class id="body">
<script>
function goBack()
{
window.history.go(-1)
}
</script>
<body>
<br><br><button onclick="goBack()">Gå tilbage og prøv igen</button>
</body>
</html>
Forside.php
<?php
session_start();
$_SESSION['loggedin'] = true;
if(isset($_SESSION['username'])) {
include('tilslut.php');
?>
<style type="text/css">@import url(css.css);</style>
<meta http-equiv="Content-Type" content="text/html;charset="UTF-8">
<table style="width:100%">
<tr>
<td width="50%"><font size="5" color="navy"><center>Familie Arrangementer<br><br></font></td>
<td width="50%" align=right><font size="5" color="navy"><center>Meddelsescenter<br><br></font></td>
</tr>
<tr>
<td><?php
$famarr = mysql_query("SELECT * FROM famarr ORDER by id DESC");
echo "<table width='100%' border='1' align='left' cellpadding='0' cellspacing='1' bgcolor='#FFFFFF'>
<tr>
<th>Navn</th>
<th>Sted</th>
<th>Dato</th>
</tr>";
while($row = mysql_fetch_array($famarr)) {
echo "<tr>";
echo "<td>" . $row['navn'] . "</td>";
echo "<td>" . $row['sted'] . "</td>";
echo "<td>" . $row['dato'] . "</td>";
echo "</tr>";
}
echo "</table>";
?></td>
<td><?php
$result = mysql_query("SELECT * FROM beskeder ORDER by dato DESC");
while($row = mysql_fetch_array($result)) {
echo "<table width='100%' border='0' align='right' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>
<tr>
<td><table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'>
<tr>
<td>Dato</td>
<td>:</td>
<td>" . $row['dato'] . "</td>
</tr>
<tr>
<td width='50'>Navn</td>
<td width='14'>:</td>
<td width='357'>" . $row['navn'] . "</td>
</tr>
<td valign='top'>Besked</td>
<td valign='top'>:</td>
<td style='word-break:break-all;'>" . $row['besked'] . "</td>
</tr>
</table><br></td>
</tr>
</table>";
echo "";
}
echo "";
?></td>
<td></td>
</tr>
<tr>
<td><center><button onclick=window.location.href='famarr/fam.php'>Tilfoej arrangement</button></td>
<td><center><button onclick=window.location.href='add/add.php'>Adressekarkotek</button> <button onclick=window.location.href='forum.php'>Skriv en besked</button> <button onclick=window.location.href='logud.php'>Log ud</button></table></td>
</tr>
</table>
<?php
} else {
?>
<center><h2><font color="navy"><br><br><br><br>Du er ikke logget ind, UPS!</font></h2></center>
<?php
}
?>
tilslut.php
<?php
$_SESSION['userName'] = '';
$host = "localhost";
$user = "root";
$pass = "";
$db = "famarr";
mysql_connect("$host", "$user", "$pass")or die("Kan ikke forbinde til databasen. :(");
mysql_select_db("$db")or die("Kan ikke finde databasen. :(");
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>