0

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);

?>

Edited by pritaeas: Moved.

3
Contributors
14
Replies
43
Views
4 Years
Discussion Span
Last Post by dorco
0

$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.

Edited by pritaeas

0
<?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);

?>

Edited by joeyliew7

0

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);

?>

Edited by pritaeas: Removed credentials.

0

not working too..

$filename=("../{$orderdate}_{$outlet}.pdf");
header('Content-type:application/pdf');
header("Content-disposition: inline; filename=file.pdf");
readfile($filename);
0
$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);
1

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.