Variables between different pages.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
karlangas79
Forum Newbie
Posts: 6
Joined: Fri Oct 21, 2011 7:42 am

Variables between different pages.

Post by karlangas79 »

Hello,

I have the index.php with a post form that sends 4 variables to a second php page.

This second page is able to read them with:

Code: Select all

$metric = $_POST['metric'];
$machine = $_POST['machine'];
$time1 = $_POST['time1'];
$time2 = $_POST['time2'];
but it has to call another php to generate a jpgraph image like this:

Code: Select all

<img src="genera_graph.php?metric=<?php echo $metric; ?>&machine=<?php echo $machine; ?>&time1=<?php echo $time1; ?>&time2=<?php echo $time2; ?>">
genera_graph.php tries to retrieve the variables with this:

Code: Select all

$metric = $_GET[metric];
$machine = $_GET[machine];
$time1 = $_GET[time1];
$time2 = $_GET[time2];
but jpgraph allways returns the error "empty input data array"

Someone realizes what I'm doing wrong?

Thanks.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Variables between different pages.

Post by Celauran »

What you've posted looks fine. Have you tried var_dump($metric) etc. in genera_graph.php to confirm they contain values?
karlangas79
Forum Newbie
Posts: 6
Joined: Fri Oct 21, 2011 7:42 am

Re: Variables between different pages.

Post by karlangas79 »

Thanks,

The problem was that i was editing the wrong file, sorry for the inconvenience.
Post Reply