Jump to content

Recommended Posts

Hi i have a simple problem here, and was hoping for a quick resolution.

 

I have a helpdesk system, where a user would log in and fill in a form.

 

When the submit button has been clicked, it'l go through to a confirmation page giving the user a reference number.

 

Now this reference number is the formID of the form, so im wanting to know how i would display the ID of the form thats just been filled in and submitted and displayed on the confirmation page.

 

Any help would be grateful.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/86465-solved-displaying-data-from-a-database/
Share on other sites

This is my code so far, which isnt quite working.

 

<?php mysql> SELECT LAST_formID()?>

$formID = mysql_formID();

 

<?php echo $formID;?>

 

On this example code here, it shows me an insert.

 

$sql = mysql_query("INSERT INTO table (column) VALUES ('$myvalue')") or die (mysql_error());

 

$insert_id = mysql_insert_id();

 

But i only want to display the last autocremented ID and not store it anywhere.

 

I think im getting abit confused, am i along the right lines ?

 

 

Not sure what code your implying here, but this is the code for the form.

 

<?php

session_start();

if (isset($_SESSION['username']) == false){

header("Location:ClientLogin.php");

exit();

}

 

    require "connect.php";

$query =  "select * from employee order by surname";

$result = @mysql_query($query, $connection)

    or die ("Unable to perform query<br>$query");

 

require "connect.php";

$query1 = "select * from form";

$result1 = mysql_query($query1, $connection)

or die ("MySQL Error: ".mysql_error());

 

?>

 

<head>

<title>Jupiter Development Support</title>

<link href="Images/mystyle.css" rel="stylesheet" type="text/css">

 

<style type="text/css">

<!--

#Layer2 {position:absolute;

width:200px;

height:52px;

z-index:2;

left: 16px;

top: 143px;

}

#Layer1 {position:absolute;

width:200px;

height:80px;

z-index:1;

left: 254px;

top: 84px;

}

.style1 {font-family: "Copperplate Gothic Bold"}

#Layer3 {

position:absolute;

width:200px;

height:115px;

z-index:3;

left: 306px;

top: 255px;

}

#Layer4 {

position:absolute;

width:200px;

height:115px;

z-index:3;

left: 842px;

top: 200px;

}

.style3 {font-family: "Copperplate Gothic Bold"; font-size: x-large; }

#Layer5 {

position:absolute;

width:400px;

height:36px;

z-index:3;

left: 390px;

top: 207px;

}

.style5 {font-family: "Copperplate Gothic Bold"; font-size: small; }

.style6 {

font-family: "Comic Sans MS";

font-size: xx-small;

}

.style7 { font-family: "Copperplate Gothic Bold";

font-size: medium;

font-weight: bold;

}

#Layer6 {

position:absolute;

width:137px;

height:130px;

z-index:4;

left: 906px;

top: 199px;

}

#Layer7 {

position:absolute;

width:82px;

height:28px;

z-index:5;

left: 91px;

top: 565px;

}

#Layer8 {

position:absolute;

width:157px;

height:43px;

z-index:5;

left: 48px;

top: 321px;

}

#Layer9 {

position:absolute;

width:163px;

height:44px;

z-index:6;

left: 47px;

top: 379px;

}

#Layer10 {

position:absolute;

width:155px;

height:44px;

z-index:7;

left: 49px;

top: 592px;

}

-->

</style>

</head>

 

<body>

 

<div id="header">

<h1 align = "center" class="style1"> </h1>

<p align = "center" class="style1"> </p>

<div id="Layer2"><img src="Images/logo.jpg" width="173" height="43"></div>

<p align = "center" class="style1"> </p>

<p align = "center" class="style1"> </p>

<div id="Layer1"><img src="Images/JDS.jpg" width="704" height="79"></div>

 

<form action="ClientFormCheck.php" method="get">

<table width="1156" border="0">

  <tr>

    <td width="1"> </td>

    <td width="66"> </td>

    <td width="108"> </td>

    <td width="62"> </td>

    <td width="204"> </td>

    <td width="195"> </td>

    <td width="16"> </td>

    <td width="161"> </td>

    <td width="284"> </td>

  </tr>

  <tr>

    <td height="68"> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td><div id="Layer6"><img src="Images/Symbol.jpg" width="135" height="129"></div></td>

  </tr>

  <tr>

    <td height="32"> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td>

      <label></label>

      <div id="Layer5"><span class="style3">Client Enquiry Form</span></div>

    <td height="32">

    <td> </td>

    <td> </td>

    <td width="17"> </td>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20"><span class="style1">Issue Title</span></td>

    <td height="20"><input name="issuetitle" type="text" id="issuetitle" value="" size="30"></td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td>

      <label></label>

    <td height="20"><span class="style1">Date of Submission </span></td>

    <td height="20"><input name="datesubmitted" type="text" id="datesubmitted" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>

    <td height="20"> </td>

    <td height="20"><div align="left"><span class="style1">Issue Number </span></div></td>

    <td height="20"><input name="ID" type="text" disabled="disabled" id="ID" size="30">

      <div id="Layer10"><a href="Adminlogout.php"><img src="Images/logOffButton.jpg" width="156" height="44" border="0"></a></div></td>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20" class="style1">Time </td>

    <td height="20"><input name="timesubmitted" type="text" id="timesubmitted" size="30" value="<?php echo $date = date("H:i")?>">

 

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><div id="Layer9"><a href="helpscreen.php"><img src="Images/helpbutton.jpg" width="163" height="44" border="0"></a></div></td>

    <td> </td>

    <td height="20"><span class="style1">Client Name </span></td>

    <td height="20"><input name="clientFname" type="text" id="clientFname" size="30" value="<?php echo $_SESSION['firstname']?>"></td>

    <td height="20"> </td>

    <td height="20"><span class="style1">Team Name </span></td>

    <td height="20"><input name="teamname" type="text" id="teamname" size="30" value="<?php echo $_SESSION['teamname']?>"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><div align="center">

      <input name="Reset" type="reset" class="style7" value="Reset">

    </div></td>

    <td> </td>

    <td height="20" class="style1"> </td>

    <td height="20"><input name="clientSurname" type="text" id="clientsurname" size="30" value="<?php echo $_SESSION['surname']?>"></td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td height="18"> </td>

    <td> </td>

    <td><div align="center"></div></td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td height="30"> </td>

    <td> </td>

    <td><div align="center">

      <input name="Submit2" type="submit" class="style7" id="Submit2" value="Submit">

    </div></td>

    <td> </td>

    <td><div id="Layer8"><a href="Mainmenu.php"><img src="Images/homepagebutton.jpg" width="161" height="41" border="0"></a></div></td>

    <td><span class="style6">Please select Appropriate System </span></td>

    <td> </td>

    <td> </td>

    <td><span class="style6">Please be accurate as this would hold up buisness Operations </span></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><div align="center"></div></td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td><span class="style1">System Affected </span></td>

    <td>

      <label>

        <select name="systemaffected" class="style1">

          <option>- - -</option>

          <option>STS</option>

          <option>SDM</option>

          <option>TSS</option>

          <option>TLM</option>

          <option>GCG</option>

          <option>SSR</option>

          <option>CER</option>

        </select>

      </label>

    <td> </td>

    <td><span class="style1">Priority Level </span></td>

    <td>

      <label>

        <select name="prioritylevel" class="style1">

          <option>- - - -</option>

          <option>High</option>

          <option>Medium</option>

          <option>Low</option>

        </select>

      </label>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td><span class="style1">Issue Details </span></td>

    <td>

      <label>

        <textarea name="issuedetails" cols="30"></textarea>

      </label>

    <td> </td>

    <td><span class="style1">Assigned To </span></td>

    <td>

      <label>

        <select name="empName" class="style1" id="analyst">

<option>- - -</option>

          <?php

        while($row= mysql_fetch_array($result)){?>

          <option > <?php echo $row['surname'];?> </option>

          <?php } ?>

</select>

</label> </td>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td class="style1"> </td>

    <td><input name="clientID" id="clientID" size="10" value="<?php echo $_SESSION['clientID']?>"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td class="style1"> </td>

    <td><input name="employeeID" id="employeeID" size="10" value="16"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

</table>

</form>

</body>

 

After it has been submitted it'l go through to another php page called confirmation.

And in a text box in that page display the last generated ID.

 

 

Oh okay sorry, here it is -

 

<?php

require "connect.php";

$issuetitle = $_GET['issuetitle'];

$datesubmitted = $_GET['datesubmitted'];

$timesubmitted = $_GET['timesubmitted'];

$systemaffected = $_GET['systemaffected'];

$prioritylevel = $_GET['prioritylevel'];

$issuedetails = $_GET['issuedetails'];

$clientFname = $_GET['clientFname'];

$clientSurname = $_GET['clientSurname'];

$teamname = $_GET['teamname'];

$empName = $_GET['empName'];

$clientID = $_GET['clientID'];

$employeeID = $_GET['employeeID'];

 

$query = "insert into form values ('','".$issuetitle."','".$datesubmitted."','".$timesubmitted."','".$systemaffected."','".$prioritylevel."','".$issuedetails."','','".$clientFname."','".$clientSurname."','".$teamname."','".$empName."','".$clientID."','".$employeeID."')";

    $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query");

header("Location: confirmation.php");

exit();

?>

Are you using sessions on all your pages?  If so, you can store it in a session variable if you want to show it on a different page.

 

$query = "insert into form values ('','".$issuetitle."','".$datesubmitted."','".$timesubmitted."','".$systemaffected."','".$prioritylevel."','".$issuedetails."','','".$clientFname."','".$clientSurname."','".$teamname."','".$empName."','".$clientID."','".$employeeID."')";
    $result = mysql_query($query, $connection) or die ("Unable to perform query
$query");

$_SESSION['insert_id'] = mysql_insert_id(); 


   header("Location: confirmation.php");
   exit();

 

Then on confirmation.php

 

echo $_SESSION['insert_id'];

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.