0

Hi this is such a basic thing, I use these all the time, but I have a page that wont pass data to the next page. I have tried a heap things over days, frustration has peaked.

form:

<form action='subq2.php' >
<input type='hidden' name='stid' value='$stid'>
<select name='eday'><option value='1'>1</option><option value='2'>2</option><option value='31'>31</option></select>
<select name='emonth'><option value='3'>Mar</option><option value='4'>April</option></select>
<input type='submit' value='Submit'>
</form>";

retrieving data on next page:

$xyx=$_GET["xyx"];
$stid=$_GET["stid"];
$ans=$_GET["ans"];

error:

Notice: Undefined variable: st in C:\wamp64\www\flightchecks\subq2.php on line 38 Call Stack # Time Memory Function Location 1 0.0002 403672 {main}( ) ...\subq2.php:0 ( ! ) Notice: Undefined variable: xyx in C:\wamp64\www\flightchecks\subq2.php on line 38 Call Stack # Time Memory Function Location 1 0.0002 403672 {main}( ) ...\subq2.php:0 ( ! ) Notice: Undefined variable: stid in C:\wamp64\www\flightchecks\subq2.php on line 38 Call Stack # Time Memory Function Location 1 0.0002 403672 {main}( ) ...\subq2.php:0 ( ! ) Notice: Undefined variable: ans in C:\wamp64\www\flightchecks\subq2.php on line 38 Call Stack # Time Memory Function Location 1 0.0002 403672 {main}( ) ...\subq2.php:0

i have tried looking online, grabbing code from all over the place, I cant get anything to work here.

thanks Quinton

brombeer
  • 8,716
  • 5
  • 21
  • 27
cue340
  • 1
  • 1
    There is no element with `name="xyx"` or `name="ans"` in your form. Their names are `eday` and `emonth`. `$stid` might be empty if you call the page without parameters – brombeer Apr 12 '20 at 06:30
  • You don't send all data that you want to your subq2.php (You just send stid, eday, emonth) . It's better show your subq2.php code. – JsMoreno Apr 12 '20 at 06:32

1 Answers1

0

I think your issue is the $_GET should probably be $_POST since the form is sent via the HTTP POST verb. Take a quick look at: https://www.w3schools.com/php/php_forms.asp

Bill
  • 88
  • 7
  • The form doesn't use `method="post"` so it is sent via GET – brombeer Apr 12 '20 at 06:28
  • What is the value of $_SERVER["REQUEST_METHOD"]? Also have you tried dumping the $_GET array to see what values it contains? Also have you tried using $_REQUEST instead of $_GET? – Bill Apr 12 '20 at 06:51
  • apologies, i did try post and get, my text above was posted from 2 different versions, apologies for that. I worked it out last night, the issue I had is I defined my time zone in the first page and not in the global include. so the times on the 2 pages where 8 hours apart, I moved the declare of time zone to the include, so it was included in all pages and everything started working right away. – cue340 Apr 13 '20 at 07:22
  • thanks for all the comments guys, appreciated!! – cue340 Apr 13 '20 at 07:22
  • Bill, that's a great idea, in the future ill try that "dumping the $_GET array" to get a better idea what is going on. – cue340 Apr 13 '20 at 07:24