View Single Post
  #8 (permalink)  
Old March 10th, 2006, 08:44 PM
Mantis Mantis is offline
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