Guys, need some help regarding this issue, i have a php file, which requests an invoice_no(invoice.php), then searches the database and returns the other value associated to it(eg,document_no,PO_no) to another php file(displaydata.php). Now the problem is, i wanna send the invoice_no not only to displaydata.php but to another file test.php.

This is what i did so far
invoice.php

<form method="post" name="form">
<h1>Enter your Invoice No.</h1>
<table>
<tr>
<td>Invoice No. :</td><td><input name="invoiceno" type="text" size"25"></input></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit" onclick="form.action='displaydata.php';"></input>
<input type="submit" name="submit" value="Back" onclick="form.action='main_login.php';"></input>

</FORM>

displaydata.php

<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="testing"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die(mysql_error());

$invoiceno=$_POST['invoiceno'];

$sql="SELECT * FROM $tbl_name WHERE invoice_no = '$invoiceno'";
$result = mysql_query($sql);

$row = mysql_fetch_array($result) or die(mysql_error());

echo "Invoice:      ".$row['invoice_no'] . "<br>"; 
echo "Document No.:      ".$row['document_no']. "<br>"; 
echo "Number of Pallets: ".$row['no_pallets']. "<br>"; 
echo "Container No.: ".$row['container_no']. "<br>"; 
echo "Part No.: ".$row['part_no']. "<br>"; 
echo "Supplier Part No.: ".$row['spart_no']. "<br>"; 
echo "PO No.: ".$row['po_no']. "<br>"; 
echo "Status: ".$row['ship_status']. "<br>"; 

?>

thank u in advance

Member Avatar for Zagga

Hi gopi17,

could you not send the form data to test.php first, have that page do whatever it needs to, then send the data to displaydata.php (in the URL using $_GET or as session data using $_SESSION)?

hmm...the thing is i'm not doing anything to the data, in displaydata.php...just comparing and displaying anything attached to it...i'll try with the session thingy...thanks

Member Avatar for Zagga

if the display.php page is just what you pasted above, maybe you could just add the display code to the bottom of test.php, or include("display.php"); in test.php? That way you don't need to send the form data to more that 1 place.

okay...somehow i manage to solve the problem...

displaydata.php

$invoice_no=$row['invoice_no'];
$document_no=$row['document_no'];
$no_pallets=$row['no_pallets'];

$_SESSION['invoice_no']=$invoice_no;
$_SESSION['document_no']=$document_no;
$_SESSION['no_pallets']=$no_pallets;

called in a different form

scan.php

echo "Invoice number :" .$_SESSION['invoice_no']."<br>";
echo "Document No. :" .$_SESSION['document_no']."<br>";
echo "Number of Pallets.:" .$_SESSION['no_pallets']."<br>";

regarding the submit button...

<form method="post" name="form">
<input type="submit" name="submit" value="Back" onclick="form.action='main_login.php';"></input>
<input type="submit" name="submit" value="Submit" onclick="form.action='displaydata.php';"></input>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.