Solved

Open pdf file in new window from one of two folders with php

Posted on 2012-03-29
4
382 Views
Last Modified: 2012-08-13
I have two folders, one with pdf files starting with P in the Place folder, and the other with files starting with C in the Country folder.

If I use a link like
<a target='_blank' href='http//myhost.com/sort.php?trip=$row[trip_number]'>" . $row['trip_number'] . "</a>  

And than in the sort.php script use this
$trip = (isset($_GET["trip"])) ? $_GET["trip"] : 0;

What can I use to take the $_GET["trip"] and redirect the request to the right folder and open the file in the parent window. I was thinking that the if statement might work like

if $trip = p*.pdf than redirect to place/$trip, if not redirect to country/$trip and if it cant find the file echo not on file and not the 404

but as you see I have no idea how to write it. Also any other way of doing this is fine if you have one. This is all I could come up with....  Thanks
0
Comment
Question by:GD_GRAY
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 37783414
$dir="country/";
if(preg_match('/^p/i',$trip)){$dir="place/";}
0
 

Author Comment

by:GD_GRAY
ID: 37783866
Sorry to ask but how would I put that into play ?
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 500 total points
ID: 37784050
in the php script which is called by the links
0
 

Author Closing Comment

by:GD_GRAY
ID: 37784332
Wow, your the bomb. thank you . I set the redirect up to use $dir/$trip and got what i need,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP: Filling Out/Creating a PDF 29 94
$_GET call between URL 3 38
How do I remove "" from json_encode 5 20
&& operators not performing required logic 8 11
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question