i have 3, files 1. check.html 2. index.php 3. pro.php check.html having... <form action="index.php" method="post"> Password: <input type="password" name="pass"> <input type="submit" value="submit"> </form> PHP: index.php having... <?php session_start(); if(!isset($_session['pass'])) { $_SESSION['pass'] = $_POST['pass']; } $a="siva"; $b=$_SESSION['pass']; if($a==$b) { Content..! } ?> PHP: 3. pro.php <?php session_start(); $a="siva"; $b=$_SESSION['pass']; if($a == $b) { content } PHP: every thing working fine ..., but once i loged on.. if i click index.php, link the session is distroying....! what's wrong in index.php i mean if i click on check button it's showing index.php file successfully but if i click on index.php (<a href="index.php">) the sesstion again taking $_SESSION['pass'] = $_POST['pass']; any solution please
Not sure what you are trying to do there but the problem is probably that you have $_SESSION in the if condition in lowercase in the index.php
login page...., creating.. form in check.html, once user click on submit button, it will post the value to index.php...., now my question is am i write correct code in index.php, $_SESSION['pass'] = $_POST['pass']; i am sending post pass to session pass..,
if(!isset($_session['pass'])) { $_SESSION['pass'] = $_POST['pass']; } PHP: So, you assign $_POST['pass'] to $_SESSION['pass'] only if $_SESSION['pass'] is already set? I think you should do this: <?php define('PASSWORD', 'yourPass'); // Put the password on the second quote. session_start() if (!isset($_SESSION['pass'])) { // Only do this stuff if the password is submitted if (isset($_POST['pass'])) { if ($_POST['pass'] == PASSWORD) { $_SESSION['pass'] = $_POST['pass']; header("Location: index.php"); exit; } else { // Error handling goes here. } } // If the password was not submitted, then print out the form. include('check.html'); exit; } // Check the password in $_SESSION. if ($_SESSION['pass'] != PASSWORD) { exit; } ?> >>>> stuff goes here <<<< PHP: It wasn't tested, but I'm sure you can debug it. Just an idea of the sort of thing you need to do.
You are wrong there. he is assigning $_POST['pass'] to $_SESSION['pass'] only if $_SESSION['pass'] is NOT yet set. Do you see the ! ? that means NOT. Also as I mentioned before SESSION should be upper case in this line if(!isset($_session['pass'])) PHP:
I don't think anyone clearly told you yet.... $_SESSION and $_session are not the same. You need $_SESSION there.
ya i used $_SESSION .., friend., thanks yar... thanks to alllllll i got through... Thanks a lot... to alllll
Ya i am assigning $_POST['pass'] to $_SESSION['pass'] only if $_SESSION['pass'] is NOT yet set, whats wrong... there! first time it will assigning the post password to session password.., once it will set.....! the $_SESSION['pass'], pass variable for that session is ready..! and will work upto i unset it. i dont think its wrong...! guys what do you say.....! i mean if second time the page loads...! <?php session_start(); $a="siva"; $b=$_SESSION['pass']; if($a==$b) { Content..! } ?> PHP: