[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Stumped with printing a url in a php file.

Posted on 2004-09-06
4
Medium Priority
?
285 Views
Last Modified: 2006-11-17
Here is the whole file, maybe something is interfering somewhere...

<?
ob_start();
include "phphits.inc.php";
phphitsAddHit();
//include("./includes/header.html");
require_once ('Benchmark/Timer.php');
$t = new Benchmark_Timer;
$t->start();
$no = no;
$file2 = $_GET["fileid"]; // get filename from the URL
include("db.php"); // connect to db
include("ipaddy.php");
include("domain.php");
$t->setMarker ('Queried the Database!');
$t->stop();
$result1 = $t->getProfiling();
ob_end_flush();
?>
<p align="center"><a href="http://www.mysite.net<? $file2 ?>"> Download!</a>
<body bgcolor="#0099CC">
<p align="center">Time to load page: <b><? print $result1[1]['diff'] ?></b</font>




The part I am having a problem with is this line:

<p align="center"><a href="http://www.mysite.net<? $file2 ?>"> Download!</a>

I've also tried

<p align="center"><a href="http://www.mysite.net<? print $file2 ?>"> Download!</a>  AND
<p align="center"><a href="http://www.mysite.net<? print $file2; ?>"> Download!</a>

When the page is loaded, the url is only http://www.mysite.net  The information loaded by the $file2 = $_GET["fileid"]; is not carried to the url.
0
Comment
Question by:go3team
[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
  • 3
4 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 600 total points
ID: 11990645
presumably your setting it up to pass the variable to the download file so the link should be something like

<p align="center"><a href="http://www.mysite.net?fileid=<?php echo $_GET['fileid']; ?>"> Download!</a>

Anyhow, is the variable definitely being passed in the query string, the should resemble http://www.yoursite.com/page.php?fileid=something
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11990663
Something to note, if you are passing the file id between several pages it would be easier to use sessions rather then passing the variable in the query string.

eg.

first page:

session_start(); //BEFORE any output at top of page

$_SESSION['fileid'] = 23;

//OR $_SESSION['fileid'] = $fileid; OR $_SESSION['fileid'] = "id"; etc


then you can access this variable on any page just using

echo $_SESSION['fileid'];

NOTE: any page where you use sessions must ghave session_start(); at the top to initialize the session data
0
 

Author Comment

by:go3team
ID: 11990877
Thanks Diablo, the first comment was what I was looking for.  What I was doing was using {REQUEST_URI} in my .htaccess file to add the filename to the ?file= part:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?,mysite.net(/)?.*$     [NC]
RewriteRule .*\.(avi|mpg|gif|swf|mpeg|wmv|mov|asf|mpe|mp3|ra|ram|AVI|MPG|GIF|MPEG|WMV|MOV|ASF|MPE|MP3|RA|RAM)$ http://www.mysite.net/test/sendfile.php?file=%{REQUEST_URI} [R,NC]

The other file ended up being:

<?
ob_start();
include "phphits.inc.php";
phphitsAddHit();
//include("./includes/header.html");
require_once ('Benchmark/Timer.php');
$t = new Benchmark_Timer;
$t->start();
$no = no;
$file2 = $_GET["file"]; // get filename from the URL
include("db.php"); // connect to db
include("ipaddy.php");
include("domain.php");
$t->setMarker ('Queried the Database!');
$t->stop();
$result1 = $t->getProfiling();
ob_end_flush();
?>
<p align="center"><a href="http://www.mysite.net<? echo $file2 ?>"> Download!</a>
<body bgcolor="#0099CC">
<p align="center">Time to load page: <b><? print $result1[1]['diff'] ?></b>font>

Working perfect!
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11990946
im glad you got it sorted :)

|)iablo
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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 count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

649 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