andyc209 Posted February 8, 2016 Share Posted February 8, 2016 i know this is PHP basics but i am trying to learn it after years of ASP I have a URL which is www.mypage.com?name='John Smith' The page for this URL has the code $BillingSurname = $_request['name']; then i have a form with hidden fields <input type="hidden" name="BillingName" value= "<?php echo $BillingSurname; ?>"> but this is not working - the variable is not passed to the form - can anyone see what i am doing wrong Quote Link to comment https://forums.phpfreaks.com/topic/300757-noobie-php-question/ Share on other sites More sharing options...
QuickOldCar Posted February 8, 2016 Share Posted February 8, 2016 (edited) You should use the method type of form such as POST or GET if know it, although REQUEST can work is extra may not need in it. Your biggest issue was the name value has to match. <?php if(isset($_REQUEST['name']) && trim($_REQUEST['name']) != ""){ $BillingSurname = $_REQUEST['name']; } else { $BillingSurname = ""; } ?> <input type="hidden" name="name" value="<?php echo $BillingSurname;?>"> Edited February 8, 2016 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/300757-noobie-php-question/#findComment-1530866 Share on other sites More sharing options...
Psycho Posted February 8, 2016 Share Posted February 8, 2016 Also, you would not put quotes around the values within the query string and the values should be URL encoded (e.g. a space would be %20 www.mypage.com?name=John%20Smith Quote Link to comment https://forums.phpfreaks.com/topic/300757-noobie-php-question/#findComment-1530876 Share on other sites More sharing options...
andyc209 Posted February 8, 2016 Author Share Posted February 8, 2016 that worked thanks - will get there with this - really time i moved away from ASP Quote Link to comment https://forums.phpfreaks.com/topic/300757-noobie-php-question/#findComment-1530878 Share on other sites More sharing options...
cyberRobot Posted February 8, 2016 Share Posted February 8, 2016 For what it's worth, PHP has a function for encoding strings to be used in a URL. More information can be found here: http://php.net/manual/en/function.urlencode.php Quote Link to comment https://forums.phpfreaks.com/topic/300757-noobie-php-question/#findComment-1530882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.