Solved

Passing variables with $_Post

Posted on 2014-04-11
8
101 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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
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

Independent Software Vendors: 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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

717 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