hoe kan ik een session id meegeven in een formulier


als ik hyperlinks maak moet ik ze altijd op deze manier neerzetten:
<?php <a href=index.php?".strip_tags(SID)."> ?>

maar hoe doe ik dat bij een formulier?

<form action="index.php" method="post">

kan eventueel mijn login script hier posten als nodig mocht zijn.
Kan je op dezelfde manier doen of via een input.

<form action="index.php?<?php echo strip_tags(SID); ?>" method="post">
</form>

of

<form action="index.php" method="post">
<input type="text of hidden" name="sid" value="<?php echo strip_tags(SID); ?>">
</form>

Of ik snap niet helemaal wat je bedoeld... :)
(doe ik ook niet, want waarom zou je een sessie-id mee willen/moeten geven?)

Elwin
tja goeie vraag misschien.

<b>LOGINPAGE.PHP</B>

<?
include("style.css");

?>

<HTML>
<HEAD>
<TITLE>BETA VERSION!!!! (TESTING ATM, DO NOT DISTURB)</TITLE>
</HEAD>

<BODY>
<form action="no-access.php" method="post">
<TABLE ALIGN="center" WIDTH="50%" BORDER="0" CELLPADDING="0" CELLSPACING="1">
<tr>
<td align="right">
<span class="kleiner">&nbsp;<b>Inloggen</b>&nbsp;</span>
</td>
</tr>
</table>
<TABLE ALIGN="center" WIDTH="50%" BORDER="0" CELLPADDING="0" CELLSPACING="1">
<TR>
<TD>
&nbsp;E-mail
</TD>
<TD>
<INPUT SIZE="30" TYPE="text" NAME="email" MAXLENGTH="25">
</TD>
</TR>
<TR>
<TD>
&nbsp;Password
</TD>
<TD>
<INPUT SIZE="30" TYPE="password" NAME="password" MAXLENGTH="30">
</TD>
</TR>
</TABLE>
<br>
<table align="center" width="50%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td align="middle">
<input type="submit" name="Login" value="Inloggen">
</td>
</tr>
</table>
<br>
<table align="center" width="50%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td align="left">
<font color="#FF7800"><a href="register.php">Register</a><br>
Password recovery<br>
E-mail recovery</font>
</td>
</tr>
</table>
</form>
</BODY>

</HTML>

<B>NO-ACCESS.PHP</B>

<?php
session_start();

include("config.inc.php");

if(isset($_POST['Login'])){

$email=strip_tags($_POST['email']);
$password=strip_tags($_POST['password']);

$chk1=substr_count(strtolower($email), "select");
$chk1+=substr_count(strtolower($email), "update");
$chk1+=substr_count(strtolower($email), "delete");
$chk1+=substr_count(strtolower($email), "insert");

$chk2=substr_count(strtolower($password), "select");
$chk2+=substr_count(strtolower($password), "update");
$chk2+=substr_count(strtolower($password), "delete");
$chk2+=substr_count(strtolower($password), "insert");

if($chk1+$chk2>0){
header("Location: loginpage.php");
}else{
//aanmeldgegevens controleren
$sql="SELECT * FROM users WHERE email='" . $email . "' AND password='" . $password . "'";
$res=mysql_query($sql);
$auth_check=mysql_num_rows($res);

if($auth_check==1){
//authenticatie geslaagd, sessie authenticeren
$_SESSION['auth']=true;
$_SESSION['timeout']=time()+3600;

//gebruikerinformatie inlezen
$user=mysql_fetch_array($res);
$_SESSION['username']=$user['username'];
$_SESSION['email']=$user['email'];
$_SESSION['status']=$user['status'];
}
}
}
//Alleen openen als er een sessie gezet is
if($_SESSION['auth'] && $_SESSION['timeout']>time()){
header("Location: index.php?".strip_tags(SID)."");
?>

<?php
//Als de sessie niet gezet is
}else{
session_destroy();
header("Location: loginpage.php");
}
mysql_close();
?>

ik weet ook niet waarom ik de sessie id moet meegeven....maar anders denkt het script dat ik niet ben ingelogd

op elke pagina doe ik:

<session_start();

if($_SESSION['auth'] && $_SESSION['timeout']>time()){
?>
hier de pagina
<?
} else {
header("Location: loginpage.php");
}
?>
dit si ingewikkeld er zijn makelijkere en betere manieren om in te loggen zenne lol
is zeg ook niet dat het super veilig is...maar dit is even een begin

Reageren