well, it seems to remember the sesion vars right, I just dont understand why it wont work anymore, before I added sessions support, I could make it work :s
here is a long part of code, just ignore all the dutch in it
I left out a lot of html, so dont look at that either, the php code is all that matters anywhay.
Page 1 - log in
<?php
session_start();
$message=""; //error message
if ($_POST['login']) { // if the user submitted
$db = mysql_connect("localhost",$dbuser,$dbpassword) || die("Unable to connect to database".mysql_error());
mysql_select_db("carege_acrogym") || die("Unable to open Database".mysql_error());
$username = $_POST['user'];
$password = $_POST['pass'];
$query = "select Email, ClubID from tblClubgegevens where lower(Clubnaam) = '".strtolower($username)."'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$num_rows = mysql_affected_rows();
if ($num_rows ==1) {
if (trim($password) == $row[0]) {
$clubid = $row[1];
$_SESSION['clubid'] = $clubid;
$location = "acrogeg2.php?".strip_tags(SID);
header("Location: $location"); /* Redirect browser */
exit; //make sure we don't execute the rest of the code when redirecting
} else {
$message = "Uw passwoord is fout! Vul uw emailadres van de club";
$message .= " als wachtwoord.";
}
} else {
$message = "Uw login en passwoord is fout! Vul uw Clubnaam in als Gebruikersnaam en het emailadres van de club";
$message .= " als wachtwoord. Indien U de juiste login gegevens ingevuld hebt, gelieve U dan in te schrijven.";
}
}
?>
<html>
<body>
<table border="0" width="100%" height="100%">
<tr><td width="100%" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="500">
<!-- invoer -->
<form name="input" method="post" action="<?php echo $_SERVER['PHP_SELF']."?".strip_tags(SID); ?>">
<table border="0"><tr><td colspan="3"><font color="red"><?php echo $message; ?></font> </td></tr>
<tr>
<td width="35%" align="right">Gebruikernaam<br><br>E-mail</td>
<td width="10%"> </td>
<td width="55%">
<input type="text" name="user" size="28"><br><br>
<input type="text" name="pass" size="28">
</td>
</tr>
</table><br>
<input type="submit" name="login" value="verder gaan"><br>
</form><br>
</td>
<td width="12"><img border="0"src="border_e.gif" width="12" height="100%"></td>
</tr>
<tr heigth="1">
<td colspan="3" bgcolor="#000000"></td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr></table>
</body></html>
page 2, this should display hte groups that belong to that specific club
<?php
session_start();
$groepid = 0;
$message = "";
if (isset($_SESSION['clubid']))
$clubid = $_SESSION['clubid'];
$db = mysql_connect("localhost", $dbuser, $dbpassword);
mysql_select_db("carege_acrogym");
if (isset($gid)) {
if ($del == true) {
mysql_query("delete from tblGymnasten where GroepID = $gid");
mysql_query("delete from tblGroepen where GroepID = $gid");
}
}
if ($_POST['toevoegen']) {
$query = "insert into tblGroepen (ClubID, categorie) values('$clubid','acro')";
echo $query;
mysql_query($query);
// give me the groep I just made
$query = "select max(GroepID) from tblGroepen where ClubID = ".$clubid."and categorie = 'acro'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
// add gymnast 1
$naam = $_POST['gymnast1'];
$geslacht = $_POST['geslacht1'];
$dag = $_POST['dag1'];
$maand = $_POST['maand1'];
$jaar = $_POST['jaar1'];
if (trim($naam) == "" || trim($geslacht) == "" || trim($dag) == "" || trim($maand) == "" || trim($jaar) == "") {
$message = "Alle velden moeten ingevuld zijn";
} else {
$datum = $jaar.'-'.$maand.'-'.$dag;
$groepid = $row[0];
$query = "insert into tblGymnasten(GroepID, Naam, Geslacht, GebDatum) values('$groepid','$naam','$geslacht','$datum')";
mysql_query($query);
}
// add gymnast 2
$naam = $_POST['gymnast2'];
$geslacht = $_POST['geslacht2'];
$dag = $_POST['dag2'];
$maand = $_POST['maand2'];
$jaar = $_POST['jaar2'];
if (trim($naam) == "" || trim($geslacht) == "" || trim($dag) == "" || trim($maand) == "" || trim($jaar) == "") {
$message = "Alle velden moeten ingevuld zijn";
} else {
$datum = $jaar.'-'.$maand.'-'.$dag;
$groepid = $row[0];
$query = "insert into tblGymnasten(GroepID, Naam, Geslacht, GebDatum) values('$groepid','$naam','$geslacht','$datum')";
mysql_query($query);
}
}
?>
<html>
<body>
<table border="0" width="100%" height="100%">
<tr><td width="100%" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="500">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr height="12">
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
<td width="12"><img border="0" src="border_nw.gif" width="12" height="12"></td>
<td width="88"><a href="clubwijz.php?<?php echo strip_tags(SID) ?>"><img border="0" src="d_club.gif" height="12" width="88"></a></td>
<td width="42"><a href="acrogeg2.php?<?php echo strip_tags(SID) ?>"><img border="0" src="a_acro.gif" height="12" width="42"></a></td>
<td width="59"><a href="tumbgeg1.php?<?php echo strip_tags(SID) ?>"><img border="0" src="d_tumb.gif" height="12" width="59"></a></td>
<td width="100%"><img border="0" src="border_n.gif" width="100%" height="12"></td>
<form name="acro" method="post" action="<?php echo $_SERVER['PHP_SELF']."?".strip_tags(SID); ?>">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" rowspan="3">
<a href="acrogeg2.php?<?php echo strip_tags(SID); ?>"><img border="0" src="btn.gif" width="9" height="11"> Duo</a><br>
<br>
<a href="acrogeg3.php?<?php echo strip_tags(SID); ?>"><img border="0" src="btn.gif" width="9" height="11"> Trio</a></td>
</table>
<input type="submit" value="Voeg toe" name="toevoegen"><p></p>
</form>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<?php
$db = mysql_connect("localhost", $dbuser, $dbpassword);
mysql_select_db("carege_acrogym");
$result = 0;
$query = "select gr.GroepID, Naam, Geslacht, GebDatum ";
$query .= "from tblGymnasten gy, tblGroepen gr ";
$query .= "where gy.GroepID = gr.GroepID and ClubID = ".$clubid." and categorie = 'acro'";
$result = mysql_query($query);
$temp = 0;
if (mysql_affected_rows() >0) {
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
if ($temp == 2) $temp = 0;
echo "<tr>\n<td>$row[0]</td><td width=\"25%\">$row[1]</td>\n";
echo "<td width=\"25%\">".(($row[2] == 'm')?"Man":"Vrouw")."</td>\n";
echo "<td width=\"25%\">$row[3]</td>";
if ($temp == 1)
echo "<td width=\"25%\"><a alt=\"Verwijder deze groep\" border=\"0\" href=\"acrogeg2.php?".strip_tags(SID)."&amp;gid=$row[0]&amp;del=true\"><img border=\"0\" src=\"btn.gif\">Verwijder</a></td></tr>\n";
else
echo "<td width=\"25%\"> </td></tr>";
$temp++;
}
} else {
echo "Er zijn geen groepen ingeschreven";
}
?>
</table>
<br><br>
</td>
<td width="12"><img border="0" src="border_e.gif" width="12" height="100%"></td>
</tr>
<tr heigth="1">
<td colspan="3" bgcolor="#000000"></td>
</tr>
</table>
</td></tr></table>
</body></html>