Solved

Passing variables with $_Post

Posted on 2014-04-11
8
93 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
  • 4
  • 4
8 Comments
 
LVL 82

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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39995251
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 82

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 82

Expert Comment

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now