Jump to content

n3wbi3

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Everything posted by n3wbi3

  1. nope what you see is what I have bump, plesae help
  2. nope what you see is what I have
  3. Yes, when I run th eprogram the session ID stays the same but the $_SESSION array seems to drop off hte face of the earth..
  4. bumping to top because I am still stuck..
  5. All the other php files are brought in via require, I did have the session_start() in all of them until someone told me not to keep them all
  6. just bumping this up because I am at my wits end..
  7. A) Sorry, will do.. == index2.php == <?php session_start(); echo session_id(); print_r($_SESSION); require "login.php"; require "header.php"; if ( $_GET['section'] ) { $function=$_GET['section']; $_SESSION['section']=$function; } print ($_SESSION["valid_user"]); verify(); if(isset($_SESSION['valid_user'])) { require "left_bar.php"; if ( $_SESSION['section'] ) { if ( $_SESSION['section'] = "resources" ) { //require "Resources.php"; } } require "main.php" ?> <table width="100%" border="0" cellspacing="20" cellpadding="4"> <tr> <td></td> </tr> <tr> <td></td> </tr> </table> </div> <!-- end of maincontent --> <?php require "footer.php"; ?> == login.php === <?php //########## Check first for a log-out request so that a new session can be started ################ if (isset($_POST['log_out'])) { session_unregister( "valid_user" ); session_destroy(); session_start(); } function write_log_in( $text ) { echo " <br><br><br> <table border=\"1\"><tr><td> <center> <p>$text</p> </center> <form method='post' action=''> <center> <table border=\"0\"> <tr><td> User ID:</td> <td> <input type='text' name='user_name' /></td></tr> <tr><td> Password:</td> <td> <input type='password' name='password' /></td></tr> </table> </center> <center> <p><input type='submit' value='Log In'></p> </center> </form> </td></tr></table> "; } // end write_log_in function //############################ Function to logout ###################### function log_out() { echo " <form method='post' action=''> <center> <INPUT TYPE=hidden NAME=log_out VALUE=\"1\"> <p><input type='submit' value='Log Out'></p> </center> </form> "; } //############################ Verify the session login information on every page! ###################### function verify() { // See if this session already includes a valid user if(isset($_SESSION["valid_user"])) { return true; } else { $user_name = $_POST["user_name"]; $password = $_POST["password"]; if ( $user_name && $password ) { // verify password and log in to database $database='MyDB'; $hostname='localhost'; $port = 50000; $username = $user; $_SESSION["hostname"] = $hostname; $_SESSION["database"] = $database; $_SESSION["user_name"] = $user_name; $_SESSION["password"] = $password; $_SESSION["port"] = $port; echo session_id(); print_r($_SESSION); $conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database; HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user_name;PWD=$password"; $conn = db2_connect($conn_string, '', ''); if ( $conn ) { $valid_user = $user_name; $_SESSION['valid_user'] = $valid_user; db2_close($conn); return true; } else { $text = "User Name and Password did not match"; echo "$text"; $text = "Welcome to IED-Infrastructure Engineering Department"; write_log_in( $text ); db2_close($conn); } } else { $text = "Welcome to IED-Infrastructure Engineering Department"; } } } ?> == Header.php == nothing but html at this point == leftbar.php == <div id="leftcontent"> <!-- Left Contents --> <table> <tr><td><h1>Contents</h1></td></tr> <tr><th>HOME</th></tr> <tr><td><a href="?section=projects" >Projects</a></td></tr> <tr><td><a href="resources.php" >Resources</a></td></tr> <tr><td><a href="?section=reports" >Reports</a></td></tr> <tr><td> </td></tr> <tr><td> </td></tr> <tr><td><h1>Quick Access</h1></td></tr> <?php if(!isset($_SESSION['valid_user'])) { echo ("<tr><th>Access online?</th></tr>"); echo ("<tr><td ><a href='login.php' ><img src='images/signon.gif' width='64' height='22' alt='Login' /></a></td></tr>"); echo ("<tr><td> </td></tr>"); echo ("<tr><th>Set up online?</th></tr>"); echo ("<tr><td ><a href='registration.php' ><img src='images/register.gif' width='68' height='22' alt='Registration' /></a></td></tr>"); echo ("<tr><td> </td></tr>"); } else { echo ("<tr><th>Change password?</th></tr>"); echo ("<tr><td><a href='External page'>click here</a></td></tr>"); echo ("<tr><td> </td></tr>"); echo ("<tr><td>"); log_out(); echo ("</tr></td>"); } ?> ==resources.php== <?php session_start(); echo session_id(); print_r($_SESSION); require "login.php"; require "header.php"; //if ( $_GET['section'] ) //{ //$function=$_GET['section']; //$_SESSION['section']=$function; //} // //print ($_SESSION["valid_user"]); ?> <center> <?php verify(); { //require "dbResource.php"; require "left_bar.php"; //require "current.php"; session_start(); function ResourceMain() { echo "<center><table border=\"1\" cellpadding=\"10\" bgcolor=\"white\"><tr> <td width=\"100\"><a href=\"set_main.php?ResTask=createResources\"><b>CreateResources</b></a></td> <td width=\"100\"><a href=\"set_main.php?ResTask=updateResources\"><b>UpdateResources</b></a></td> <td width=\"100\"><a href=\"set_main.php?ResTask=removeResources\"><b>RemoveResources</b></a></td> <td width=\"100\"><a href=\"set_main.php?ResTask=listResources\"><b>ListResources</b></a></td> </tr></table></center>"; } //function viewManagers() //{ echo "</center>"; $managers=dbquery( "select * from iepp01.manager"); $i=0; $resultSize=count($managers); echo "<br/><br/>"; echo "<ul>"; while ( $i < $resultSize) { print ("<li><b>".$managers["$i"]['1']."</b> <a href=\"set_main.php?ResTask=viewManagersEmps?ManID=$i\">View Employees</a></li>"); $i += 1; } echo "</ul>"; //} ResourceMain(); } ?>
  8. Im trying to go to a second page (sorry I forgot to post it, here it is) <?php session_start(); echo session_id(); print_r($_SESSION); require "login.php"; require "header.php"; //if ( $_GET['section'] ) //{ //$function=$_GET['section']; //$_SESSION['section']=$function; //} // //print ($_SESSION["valid_user"]); ?> <center> <?php verify(); { //require "dbResource.php"; require "left_bar.php"; //require "current.php"; session_start(); function ResourceMain() { echo "<center><table border=\"1\" cellpadding=\"10\" bgcolor=\"white\"><tr> <td width=\"100\"><a href=\"set_main.php?ResTask=createResources\"><b>CreateResources</b></a></td> <td width=\"100\"><a href=\"set_main.php?ResTask=updateResources\"><b>UpdateResources</b></a></td> <td width=\"100\"><a href=\"set_main.php?ResTask=removeResources\"><b>RemoveResources</b></a></td> <td width=\"100\"><a href=\"set_main.php?ResTask=listResources\"><b>ListResources</b></a></td> </tr></table></center>"; } //function viewManagers() //{ echo "</center>"; $managers=dbquery( "select * from iepp01.manager"); $i=0; $resultSize=count($managers); echo "<br/><br/>"; echo "<ul>"; while ( $i < $resultSize) { print ("<li><b>".$managers["$i"]['1']."</b> <a href=\"set_main.php?ResTask=viewManagersEmps?ManID=$i\">View Employees</a></li>"); $i += 1; } echo "</ul>"; //} ResourceMain(); } ?> -- without having to log in again, the session stays the same but all vars are lost fo verify(); fails
  9. Well register_globals = Off, so I will provide as much code as I can == index2.php == <?php session_start(); echo session_id(); print_r($_SESSION); require "login.php"; require "header.php"; if ( $_GET['section'] ) { $function=$_GET['section']; $_SESSION['section']=$function; } print ($_SESSION["valid_user"]); verify(); if(isset($_SESSION['valid_user'])) { require "left_bar.php"; if ( $_SESSION['section'] ) { if ( $_SESSION['section'] = "resources" ) { //require "Resources.php"; } } require "main.php" ?> <table width="100%" border="0" cellspacing="20" cellpadding="4"> <tr> <td></td> </tr> <tr> <td></td> </tr> </table> </div> <!-- end of maincontent --> <?php require "footer.php"; ?> == login.php === <?php //########## Check first for a log-out request so that a new session can be started ################ if (isset($_POST['log_out'])) { session_unregister( "valid_user" ); session_destroy(); session_start(); } function write_log_in( $text ) { echo " <br><br><br> <table border=\"1\"><tr><td> <center> <p>$text</p> </center> <form method='post' action=''> <center> <table border=\"0\"> <tr><td> User ID:</td> <td> <input type='text' name='user_name' /></td></tr> <tr><td> Password:</td> <td> <input type='password' name='password' /></td></tr> </table> </center> <center> <p><input type='submit' value='Log In'></p> </center> </form> </td></tr></table> "; } // end write_log_in function //############################ Function to logout ###################### function log_out() { echo " <form method='post' action=''> <center> <INPUT TYPE=hidden NAME=log_out VALUE=\"1\"> <p><input type='submit' value='Log Out'></p> </center> </form> "; } //############################ Verify the session login information on every page! ###################### function verify() { // See if this session already includes a valid user if(isset($_SESSION["valid_user"])) { return true; } else { $user_name = $_POST["user_name"]; $password = $_POST["password"]; if ( $user_name && $password ) { // verify password and log in to database $database='MyDB'; $hostname='localhost'; $port = 50000; $username = $user; $_SESSION["hostname"] = $hostname; $_SESSION["database"] = $database; $_SESSION["user_name"] = $user_name; $_SESSION["password"] = $password; $_SESSION["port"] = $port; echo session_id(); print_r($_SESSION); $conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database; HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user_name;PWD=$password"; $conn = db2_connect($conn_string, '', ''); if ( $conn ) { $valid_user = $user_name; $_SESSION['valid_user'] = $valid_user; db2_close($conn); return true; } else { $text = "User Name and Password did not match"; echo "$text"; $text = "Welcome to IED-Infrastructure Engineering Department"; write_log_in( $text ); db2_close($conn); } } else { $text = "Welcome to IED-Infrastructure Engineering Department"; } } } ?> == Header.php == nothing but html at this point == leftbar.php == <div id="leftcontent"> <!-- Left Contents --> <table> <tr><td><h1>Contents</h1></td></tr> <tr><th>HOME</th></tr> <tr><td><a href="?section=projects" >Projects</a></td></tr> <tr><td><a href="resources.php" >Resources</a></td></tr> <tr><td><a href="?section=reports" >Reports</a></td></tr> <tr><td> </td></tr> <tr><td> </td></tr> <tr><td><h1>Quick Access</h1></td></tr> <?php if(!isset($_SESSION['valid_user'])) { echo ("<tr><th>Access online?</th></tr>"); echo ("<tr><td ><a href='login.php' ><img src='images/signon.gif' width='64' height='22' alt='Login' /></a></td></tr>"); echo ("<tr><td> </td></tr>"); echo ("<tr><th>Set up online?</th></tr>"); echo ("<tr><td ><a href='registration.php' ><img src='images/register.gif' width='68' height='22' alt='Registration' /></a></td></tr>"); echo ("<tr><td> </td></tr>"); } else { echo ("<tr><th>Change password?</th></tr>"); echo ("<tr><td><a href='External page'>click here</a></td></tr>"); echo ("<tr><td> </td></tr>"); echo ("<tr><td>"); log_out(); echo ("</tr></td>"); } ?>
  10. I get that but when I follow a link on the page to another with basically the same format header.php body2.php I get a blank array and the login screen again (I run verify on very page)
  11. Yes the session save path is valid, I am linking via local reference (a href="foo.php")... I have tinkered with this fo a couple of days and in some of my meager debugging I have discovered this: the index file is goes like this (pseudocode) import header.php import login.php import body.php header (right now) just has this start_session pring session id print_r $_SESSION body has this start_session pring session id print_r $_SESSION verify() -- verify just check to see if its a valid user and if it is not it prints up the login screen. Going to the page initially I get the log in screen, and when I log in I see this SessionID=1asdf2, Array () <=== from the header SessionID=1asdf2, Array (login=bob) <=== from the body
  12. Relative links, as to the session paths and error reporting... Im kind of new at this.. where do I set up the path?
  13. Long story short: I have a php application using DB2 as a database back end. Im new php sessions this is what I am doing -- index.php -- <?php session_start(); require "login.php"; require "header.php"; if ( $_GET['section'] ) { $function=$_GET['section']; $_SESSION['section']=$function; } print ($_SESSION["valid_user"]); ?> <center> <?php verify(); echo session_id(); print_r($_SESSION); ?> -- header.php -- <?php session_start(); echo session_id(); print_r($_SESSION); ?> == What I am noticing is that while the session data shows up in the main body of index.php but not in the header... ever.. I also have a link pointing to another page (resources.php) which carries over the session id but not the session data..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.