I want to display pdf file in browser.
odo1.php has the file to select the date.
read.php will read the date from odo1.php.
i have this files 2013-03-26_SAP.pdf, 2013-03-05_SAP and more to come.
the name of this file is combination of date and outlet.
when i change the readfile($filename); to 2013-03-05_SAP.pdf it work well.
pls help.

file:odo1.php

<form id="contact-form" action="read.php" onsubmit="return validate()" method="post" enctype="multipart/form-data">
                      <fieldset>
                          <h4>
                        Order Date: <input type="date" name="orderdate">

                    </h4>

                        </fieldset>
                        <p></p>
                      <input type="submit" name="submit" value="View Delivery Order" />


                </form>

read.php

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();

$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$outlet=("SELECT outlet  
FROM pstaff  
WHERE  staff_id='$id'
");
$orderdate=$_POST['orderdate'];

$filename=('../'.'$orderdate'.'_'.'$outlet'.'.pdf');
header('Content-type:application/pdf');
readfile($filename);

?>

$filename=('../'.'$orderdate'.'_'.'$outlet'.'.pdf');

Variables are NOT PARSED within single quotes. Try this:

$filename=("../{$orderdate}_{$outlet}.pdf");

Apart from that, you never execute the query on line 9. You should use mysql_query and mysql_fetch_array to get the data you need.

cannot..fail to load pdf document

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();

$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$outlet=("SELECT outlet  
FROM pstaff  
WHERE  staff_id='$id'
");
$orderdate=$_POST['orderdate'];

$filename=("../{$orderdate}_{$outlet}.pdf");
header('Content-type:application/pdf');
readfile($filename);

?>

it this what u mean?

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();

$con=mysql_connect("#","#","#");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$outlet=("SELECT outlet  
FROM pstaff  
WHERE  staff_id='$id'
");
$outlet1=mysql_query($outlet);
while($row = mysql_fetch_array($outlet1))
            {
                echo $row['odate'];
                echo $row['outlet'];
            }

$orderdate=$_POST['orderdate'];

$filename=("../{$orderdate}_{$outlet}.pdf");
header('Content-type:application/pdf');
readfile($filename);

?>

yea..its not displaying the pdf file

try adding header("Content-disposition: inline; filename=file.pdf");

not working too..

$filename=("../{$orderdate}_{$outlet}.pdf");
header('Content-type:application/pdf');
header("Content-disposition: inline; filename=file.pdf");
readfile($filename);

how do i call the value?

$qoutlet=("SELECT outlet  
FROM pstaff  
WHERE  staff_id='$id'
");
$outlet1=mysql_query($qoutlet);
while($row = mysql_fetch_array($outlet1))
            {

                echo $row['outlet'];
            }

$orderdate=$_POST['orderdate'];
$outlet=isset($row['outlet']);

$filename=("$orderdate.pdf");
header('Content-type:application/pdf');
header("Content-disposition: inline; filename=file.pdf");
readfile($filename);

header("Content-disposition: inline; filename=the_name_of_file.pdf");
not the exact text. add the file name..

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.