Solved

Passing variables with $_Post

Posted on 2014-04-11
8
98 Views
Last Modified: 2014-04-12
I have a page that is getting data from a previous page.  I want to pass the same data to a third page.

I've tried this on the 1st page:
<?php
$work = "?".
                        "Min_Store = ".$Min_Store." ".
                        "Max_Store = ".$Max_Store." ";
?>
<a href =  "Survey_Print.php
      <?php
            echo $work;
      ?>
">   
<br>
                
<input name= "Print" type="button" id="Print" value="<?= $Button_Value; ?>"

Then on the 3rd page, I have:

echo "Min = ";
echo $_GET['Min_Store'];
echo "<br>";
$Min_Store = $_GET['Min_Store'];
$Max_Store = $_GET['Max_Store'];

The URL on the 3rd page looks correct, however I'm not getting the data.
The echo on page 3 just says "Min = ".
What am  I missing.

Glenn
0
Comment
Question by:breeze351
[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
  • 4
  • 4
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39995076
The first thing is that there should not be any spaces in a URL, especially in a 'name' for a name/value pair.  Second is that all the values should be urlencoded to prevent them from 'breaking' the URL.  http://us3.php.net/manual/en/function.urlencode.php  Third, each 'name' after the first one needs to be prefixed with an '&' although '&amp;' is considered to be a better choice.

It should end up looking like this:

Survey_Print.php?Min_Store=Min_Store_value&amp;Max_Store=Max_Store_value

Or like this:

Survey_Print.php?Min_Store=123&amp;Max_Store=456
0
 

Author Comment

by:breeze351
ID: 39995181
I changed the code to read:
$work = "?".
                        "Min_Store=".$Min_Store."&;".
                        "Max_Store=".$Max_Store;

The URL is displaying:

http://chris.mrbreeze.net/Survey_Print.php?Min_Store=2000&;Max_Store=3500

The echo is still returning "Min = "

I just tried something and it works.  I changed $_POST to $_GET.

What's up with this?

Glenn
0
 

Author Comment

by:breeze351
ID: 39995242
Min works with the $_GET but Max is returning blank.
0
Industry Leaders: 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!

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39995251
0
 

Author Comment

by:breeze351
ID: 39996460
Ok.
I duplicated the code from your previous post:
Survey_Print.php?Min_Store=123&amp;Max_Store=456

So get rid of that ";" after the "&amp".

Glenn
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39996541
No, you didn't.  Somehow you put an extra ';' in there.  It's either '&' or '&amp;' but Not '&;' and not '&amp;;'.
0
 

Author Closing Comment

by:breeze351
ID: 39996630
Thanks
Glenn
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39996674
You're welcome, glad to help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

733 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