Nieuw lid |
|
hoi allemaal,
index.php
<?
session_start();
error_reporting();
require("classes/login.class.php");
$Login = new Login();
$pageid = $_GET['pageid'];
$action = $_GET['action'];
mysql_connect("localhost", "root", "");
mysql_select_db("competitie");
?>
<html>
<head>
<title>PlaceWeb</title>
<link href='style.css' type='text/css' rel='stylesheet'>
</head>
<body>
<div id='container'>
<div id='content'>
<div id='middle'>
<table width='100%'>
<tr>
<td valign='top'>
<div>
<? include('menu.php');?>
</div>
</td>
<td valign='top'>
<div id='news'>
<?
switch ($pageid)
{
case 'login':
if ($action == 'form')
{
$Login -> form();
}
if ($action == 'check')
{
$Login -> check();
}
break;
default:
{
$Login -> form();
}
break;
}
?>
</div>
</td>
</tr>
</table>
</div>
</div>
© 2006 - C.Jongman versie 1.0 - Alle rechten voorbehouden.
</div>
</body>
</html>
<? require("classes/login.class.php"); $Login = new Login(); $pageid = $_GET['pageid']; $action = $_GET['action']; ?> <html> <head> <title>PlaceWeb</title> <link href='style.css' type='text/css' rel='stylesheet'> </head> <body> <div id='container'> <div id='content'> <div id='middle'> <table width='100%'> <tr> <td valign='top'> <div> <? include('menu.php');?> </div> </td> <td valign='top'> <div id='news'> <? switch ($pageid) { case 'login': if ($action == 'form') { $Login -> form(); } if ($action == 'check') { $Login -> check(); } break; default: { $Login -> form(); } break; } ?> </div> </td> </tr> </table> </div> </div> © 2006 - C.Jongman versie 1.0 - Alle rechten voorbehouden. </div> </body> </html>
En de login.class.php
<?php
class Login
{
function form()
{
?>
<form method='post' action='index.php?pageid=login&action=check'>
<table align='center'>
<tr>
<td>Gebruikersnaam:</td>
<td><input id='input-text' type='text' name='username2'></td>
</tr>
<tr>
<td>Wachtwoord:</td>
<td><input id='input-text' type='password' name='password2'></td>
</tr>
<tr>
<td align='center' colspan='2'><input id='button' type='submit' name='submit' value='Login'></td>
</tr>
</table>
</form>
<?
}
function check()
{
$postedusername = $_POST['username2'];
$postedpassword = $_POST['password2'];
$query = "SELECT * FROM users";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
extract($row);
if ($postedusername == '$username')
{
if ($postedpassword != '$password')
{
?>
<table border='0' align='center' width='95%'>
<tr>
<td align='center'>Fout wachtwoord.</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align='center'><a href='index.php'>Back</a></td>
</tr>
</table>
<?
}
else
{
$_SESSION['username'] = $postedusername;
?>
<table border='0' align='center' width='95%'>
<tr>
<td align='center'>Gelukt.</td>
</tr>
<tr>
<td> <a href='index.php'>index</a></td>
</tr>
</table>
<?
}
}
}
}
?>
<?php class Login { function form() { ?> <form method='post' action='index.php?pageid=login&action=check'> <table align='center'> <tr> <td>Gebruikersnaam:</td> <td><input id='input-text' type='text' name='username2'></td> </tr> <tr> <td>Wachtwoord:</td> <td><input id='input-text' type='password' name='password2'></td> </tr> <tr> <td align='center' colspan='2'><input id='button' type='submit' name='submit' value='Login'></td> </tr> </table> </form> <? } function check() { $postedusername = $_POST['username2']; $postedpassword = $_POST['password2']; $query = "SELECT * FROM users"; if ($postedusername == '$username') { if ($postedpassword != '$password') { ?> <table border='0' align='center' width='95%'> <tr> <td align='center'>Fout wachtwoord.</td> </tr> <tr> <td> </td> </tr> <tr> <td align='center'><a href='index.php'>Back</a></td> </tr> </table> <? } else { $_SESSION['username'] = $postedusername; ?> <table border='0' align='center' width='95%'> <tr> <td align='center'>Gelukt.</td> </tr> <tr> <td> <a href='index.php'>index</a></td> </tr> </table> <? } } } } ?>
Nu is mijn vraag, ik post mijn gegevens over, maar neemt de var $username niet overal mee naartoe. De sessie blijft dus niet bestaan, lijkt het.
Ik krijg de foutmeldingen:
Notice: Undefined index: pageid in c:\easyphp1-8\www\competitie\index.php on line 10
Notice: Undefined index: action in c:\easyphp1-8\www\competitie\index.php on line 11
En de var $username fout:
Notice: Undefined variable: susername in c:\easyphp1-8\www\competitie\menu.php on line 15
Ik zal wel weer zon lullig foutje hebben gemaakt. Ik hoop dat iemand mij kane helpen.
alvast bedankt
|