View Single Post
  #3 (permalink)  
Old March 9th, 2006, 06:39 PM
mall9@hotmail.com mall9@hotmail.com is offline
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