Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 1st, 2006, 02:04 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Difficulty with $_SESSION

Hello to everyone reading this.

I am a beginner to PHP, and i am experiencing a few problems with SESSIONS I have set up in a web site I am trying to develop.

My site requires users to login via a username and password, in which I have used session_start();, so I can use this information on the next page. I am incorporating this into all of my pages where I retrieve the username and display it in all the following page headings, welcoming that user to the new page.

Upon logging in, I ask the user to choose what they would like to do next, and all of my links carry over their details I request to their desired next page.

One of the option links requires the user to fill in all the fields. If they choose this and do not enter all the fields and try to submit it an error page is displayed, which I have created which again echoes the session information telling them there is an error. They can resume information entry at this point and submit the form.

Upon completing the form and submitting it, the user gets a confirmation message for a successful submission with the session information also being carried over. Eg Thank you Tim etc...

On this confirmation page, I ask the user if they would like to do the same thing again or go back to the homepage, where of course they choose the appropriate link.

MY PROBLEM OCCURS HERE: either link looses the session information, and I DON'T KNOW WHY! AHHHHHHHHHHHHHHHHHHHH:(.

I have one form, with all the code, which works perfectly until the links are used, at which point I loose all the session info which messes up everything, because the session information is vital.

The only way around it for me at the moment is the have the link redirect them to the login stage again, where of course the session information is re-invoked. That works for now, but it is inefficient!

If anyone can please help me, I would be very greatful.

Thank you.

H.
Reply With Quote
  #2 (permalink)  
Old March 6th, 2006, 12:06 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yo!
Hello everyone, i am back!!! been a while you know.

so mall9, two suggestions. go through this tutorial and carefully read and do it yourself. once you do that and still can't find your problem, post your codes and we'll see how it'll go from there

http://www.phpfreaks.com/tutorials/40/0.php



----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
Reply With Quote
  #3 (permalink)  
Old March 9th, 2006, 06:39 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Gotaka4, thankyou for your reply. I had a look through the tutorial you sent me via the link, and i am still having problems. I think it's because of my inexperience of PHP which is the most annoying thing.

If you could take a look at my code and hopefully see the problem. Cheers.

---------------------------------------------
<?
session_start();
include "conn2.inc.php";
//Links to the helpdesk database
?>

<?
// I have used this code below, so I can retrieve some fields from the staff db,
//which i haven't used in the session, for example First_Name.

include "conn2.inc.php";
$query ="SELECT * FROM staff WHERE StaffID= '" . $_SESSION['staff_logged']."'
AND Password =(password('" . $_SESSION['staff_password'] . "'));";
$result = mysql_query($query) or die(mysql_error());
$new = mysql_fetch_array($result);
?>

<html>
<head>
<body background="h.gif">
<body>

<?
include "conn1.inc.php";


    if ($_POST['submit'] == "Submit")
    {
    if ($_POST['StaffID'] != "" && $_POST['Date'] != "" && $_POST['Time'] != "" &&
        $_POST['Location'] != "" && $_POST['DeviceID'] != "" && $_POST['Problem_Desc'] != "")

    {
    $user= $_POST['StaffID'];

    $q1 = "SELECT StaffID
               FROM fault_form
               WHERE StaffID = 'user';";

    $result = mysql_query($q1) or die(mysql_error());
    if (mysql_num_rows($result) != 0)
        {


?>
            <br>You have already made this request
            , <?php echo $_POST['StaffID']; ?>,
            Enter another!</b>

<?
include "conn1.inc.php";
?>

<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<? echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<? echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<? print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<? echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<? echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>

//Updating the database

<?
    }
     else
    {

    $q8 = "INSERT INTO fault(StaffID, Date, Time, Location,
        DeviceID, Problem_Desc)
        VALUES ('" . $_POST['StaffID'] . "', '" . $_POST['Date'] ."',
        '" . $_POST['Time'] . "', '" . $_POST['Location'] ."',
        '" . $_POST['DeviceID'] . "', '". $_POST['Problem_Desc'] ."');";

        $result = mysql_query($q8) or die(mysql_error());
        $_SESSION['staff_logged'] = $_POST['staffID'];
        $_SESSION['staff_password'] = $_POST['password'];
?>


<br>
<div align="center"><h2>Confirmation.<br> <? echo $new['StaffID']; ?> Your Fault Was Submitted Successfully!</h2></div><br>
<div align="center"><h4>Thankyou for completing the Fault Reporting Form,<br> the fault reported will be looked at a.s.a.p<br>
<br>
Please check your account regularly for updates on your reported fault.<br><br>

To report another fault <a href="staff_homepage.php">Click Here</a>.<br><br>

To return to the Homepage <a href="logged_staff.php">Click Here</a>.<br>

<?

        }
    }
    else
    {
?>

<br>

    <b><div align="center"><h2><? echo $new['StaffID']; ?> You Have Encountered A Fault Error.<br>All Details Are Required!</h2>
    <h4>Check that your StaffID, Date, Time, Location, DeviceID <br> Problem Description
    of no more that 250 words has been entered!</h4></div></b><br>


<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<? echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<? echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<? print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<? echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<? echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>

<?
    }
}
else
{

//First page of error/problem form
?>

<br>
<div align="center"><h2>Welcome <? echo $new['StaffID']; ?>,<br> To The Fault Reporting Page</h2></div>
<div align="center"><h4>Please Enter The Relevant Information Into The Fields Provided <br> & Press Submit</h4>
<br>

<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<? echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<? echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<? print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<? echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<? echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>
<?
}
?>
</BODY>
</HTML>

------------------------------------------

That's it. Hope you have better luck than i do.

Hope to hear from you soon.

Thanks

H.


Reply With Quote
  #4 (permalink)  
Old March 9th, 2006, 11:24 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

are these all in one file or separate files? if so, please make clear.

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
Reply With Quote
  #5 (permalink)  
Old March 10th, 2006, 04:28 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah sorry, this is all one php file creating a single form. From the very bottom, that is my initail page to the user. If the user does not fill in all the relevant fields they get an error message, and a chance to fill in the form again. Upon a successful submission they get a confirmation page, with links to report another fault or return to the hompepage.

It works as it is meant to the very first time it is used, but once i click on either of the links : if you would like to report another fault OR return to the homepage link, all the session information is lost.

PLEASE NOTE: Even with the session information missing after clicking either link, if i want to report another fault, it works. It's just that the user has to type in their username etc, when before it would find it from the session information.

Any problems, just let me know.

Thanks

H.

Reply With Quote
  #6 (permalink)  
Old March 10th, 2006, 11:53 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

let's change these lines first:

$q1 = "SELECT StaffID
               FROM fault_form
               WHERE StaffID = 'user';";

to:

$ql = "SELECT StaffID FROM fault_form WHERE StaffID = '$user'";

try that and tell me what error you are getting exactly as it appears on your browser.

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
Reply With Quote
  #7 (permalink)  
Old March 10th, 2006, 07:39 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I gave that a go, and it looked to make sense. Im not getting a syntax error from the php code, BUT i am getting the error message that i have already posted the exact same problem when i have not.

So it's outputing the code:


?>
            <br>You have already made this request
            , <?php echo $_POST['StaffID']; ?>,
            Enter another!</b>

<?
include "conn1.inc.php";
?>

<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<? echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<? echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<? print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<? echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<? echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>

------------------------------------------

im also getting the //Updating the database message dispayed. Weird!

Hope this makes sense.

By the way, when you reply the next time, can you just state the time in 24 hour format so I know when it's best time to possibly respond to each other.

Thanks for the help

Appreciate it.

Hope to hear from you soon.

Reply With Quote
  #8 (permalink)  
Old March 10th, 2006, 08:44 PM
Friend of Wrox
 
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have modified your code.

On my server, <? doesn't activate php ; I have to use <?php
also,
// text explication is for php
<!-- text explication --!> is for html
so be carrefull where you place them.

Last: session_start(); needs to placed at the top of every file you create otherwise it stop the session.

Hopefully that will work better.


<?php
session_start();
include "conn2.inc.php";
//Links to the helpdesk database
?>

<?php
// I have used this code below, so I can retrieve some fields from the staff db,
//which i haven't used in the session, for example First_Name.

include "conn2.inc.php";
$query ="SELECT * FROM staff WHERE StaffID= '" . $_SESSION['staff_logged']."'
AND Password =(password('" . $_SESSION['staff_password'] . "'));";
$result = mysql_query($query) or die(mysql_error());
$new = mysql_fetch_array($result);
?>

<html>
<head>
<body background="h.gif">
<body>

<?php
include "conn1.inc.php";


    if ($_POST['submit'] == "Submit")
    {
    if ($_POST['StaffID'] != "" && $_POST['Date'] != "" && $_POST['Time'] != "" &&
        $_POST['Location'] != "" && $_POST['DeviceID'] != "" && $_POST['Problem_Desc'] != "")

    {
    $user= $_POST['StaffID'];

    $q1 = "SELECT StaffID
               FROM fault_form
               WHERE StaffID = 'user';";

    $result = mysql_query($q1) or die(mysql_error());
    if (mysql_num_rows($result) != 0)
        {


?>
            <br>You have already made this request
            , <?php echo $_POST['StaffID']; ?>,
            Enter another!</b>

<?php
include "conn1.inc.php";
?>

<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<?php echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<?php echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<?php print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<?php echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<?php echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?php
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>

<!-- Updating the database --!>

<?php
    }
     else
    {

    $q8 = "INSERT INTO fault(StaffID, Date, Time, Location,
        DeviceID, Problem_Desc)
        VALUES ('" . $_POST['StaffID'] . "', '" . $_POST['Date'] ."',
        '" . $_POST['Time'] . "', '" . $_POST['Location'] ."',
        '" . $_POST['DeviceID'] . "', '". $_POST['Problem_Desc'] ."');";

        $result = mysql_query($q8) or die(mysql_error());
        $_SESSION['staff_logged'] = $_POST['staffID'];
        $_SESSION['staff_password'] = $_POST['password'];
?>


<br>
<div align="center"><h2>Confirmation.<br> <? echo $new['StaffID']; ?> Your Fault Was Submitted Successfully!</h2></div><br>
<div align="center"><h4>Thankyou for completing the Fault Reporting Form,<br> the fault reported will be looked at

a.s.a.p<br>
<br>
Please check your account regularly for updates on your reported fault.<br><br>

To report another fault <a href="staff_homepage.php">Click Here</a>.<br><br>

To return to the Homepage <a href="logged_staff.php">Click Here</a>.<br>

<?php

        }
    }
    else
    {
?>

<br>

    <b><div align="center"><h2><? echo $new['StaffID']; ?> You Have Encountered A Fault Error.<br>All

Details Are Required!</h2>
    <h4>Check that your StaffID, Date, Time, Location, DeviceID <br> Problem Description
    of no more that 250 words has been entered!</h4></div></b><br>


<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<?php echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<?php echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<?php print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<?php echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<?php echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?php
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>

<?php
    }
}
else
{

//First page of error/problem form
?>

<br>
<div align="center"><h2>Welcome <? echo $new['StaffID']; ?>,<br> To The Fault Reporting Page</h2></div>
<div align="center"><h4>Please Enter The Relevant Information Into The Fields Provided <br> & Press Submit</h4>
<br>

<FORM action="fault_form.php" method="post">

      <table border="5" cellpadding="1" cellspacing="2" align="center">

        <tr>
        <td bgcolor="">
          StaffID:
        </td>
        <td bgcolor="">
          <input type="text" name="StaffID" value="<?php echo
            $_SESSION['staff_logged']; ?>"><br>
        </td>
        </tr>
        <tr>
        <td bgcolor="">
          Date:
        </td>
        <td bgcolor="">
          <input type="text" name="Date" value="<?php echo
            $today = date("Y/m/d"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Time:
        </td>
        <td bgcolor="">
          <input type="text" name="Time" value="<?php print date("H:i:s"); ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Location:
        </td>
        <td bgcolor="">
          <input type="text" name="Location" value="<?php echo
            $_POST['Location']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          DeviceID:
        </td>
        <td bgcolor="">
          <input type="text" name="DeviceID" value="<?php echo
            $_POST['DeviceID']; ?>"><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="">
          Please enter brief description of problem<br>
          (250 Words Max):
        </td>
        <td bgcolor="">
          <textarea name="Problem_Desc" rows="2" cols="16" value="<?php
          echo $_POST['Problem_Desc'];?>"></textarea><br>
        </td>
        </tr>

        <tr>
        <td bgcolor="" colspan=2 align="center">
          <input type="submit" name="submit" value="Submit">
          <input type="reset" value="Clear">
        </td>
        </tr>
    </table

  </form>
<?php
}
?>
</BODY>
</HTML>
Reply With Quote
  #9 (permalink)  
Old March 10th, 2006, 09:20 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mantis for your helpful tips with the commenting. I learnt something new there. :)

As for the session, well i have set the session to start on all of my pages, and my problem only occurs at this stage on my site. When the confirmation message is displayed and brings up the links, somehow the information is lost at this stage.

The confirmation message carries over session information, but as soon as either of my links are used, the session information is lost.

My initial thoughts were, you can't pass a session through one form more than once, but im not sure if that is true. Unless there is an explanation with sessions and links being combined together. To be honest im totally lost at this point seeing as all my other session work perfectly.

Im sure the answer is out there somewhere.

Thanks again for your reply.

H.

Reply With Quote
  #10 (permalink)  
Old March 11th, 2006, 06:30 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perso I won't use the $_SESSION['variable'] as a "variable carrier" - I had issue where PHP wouldn't return the variable in the past until I refresh the page..

What I do is assign the session variable to a variable just below the session start.

$staff_logged=$_SESSION['staff_logged'];

also looking at the code,
$q8 = "INSERT INTO fault(StaffID, Date, Time, Location, DeviceID, Problem_Desc)
        VALUES ('" . $_POST['StaffID'] . "', '" . $_POST['Date'] ."',
        '" . $_POST['Time'] . "', '" . $_POST['Location'] ."',
        '" . $_POST['DeviceID'] . "', '". $_POST['Problem_Desc'] ."');";

        $result = mysql_query($q8) or die(mysql_error());
        $_SESSION['staff_logged'] = $_POST['staffID'];
        $_SESSION['staff_password'] = $_POST['password'];

Try instead:
$_SESSION['staff_logged'] = $_POST['staffID'];
$_SESSION['staff_password'] = $_POST['password'];
$staff_logged = $_POST['staffID'];
$staff_password = $_POST['password'];

And modify your code; replace all the $_SESSION['staff_logged'] and $_SESSION['staff_password'] by $staff_logged and $staff_password.

On the next page $staff_logged=$_SESSION['staff_logged']; and $staff_password=$_SESSION['staff_password'];

Give that a try
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
$_SESSION error in login.php Mind Games Beginning PHP 1 June 2nd, 2008 03:43 PM
$_Session cant pass Value kelz84 Beginning PHP 1 March 21st, 2006 09:25 AM
Is it possible to set $_Session Variables in java rinventive Java Basics 1 February 13th, 2006 05:41 AM
Difficulty getting thePhile up and running tkubaska BOOK: ASP.NET Website Programming Problem-Design-Solution 3 April 5th, 2004 12:32 PM
$_SESSION vs. $_GLOBALS Moharo Pro PHP 2 August 18th, 2003 02:27 PM



All times are GMT -4. The time now is 08:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.