simonp Posted December 12, 2008 Share Posted December 12, 2008 We trying to stop using register_globals but this code we have doesn't work without it. What would we need to change? // only validate form when form is submitted if(isset($submit_button)){ $error_msg=''; if($pagerName=='') { $error_msg.="<li>Please tell us your name</li>"; } if($pagerPhone=='') { $error_msg.="<li>Please tell us telephone number</li>"; } Thanks! Simon Link to comment https://forums.phpfreaks.com/topic/136679-get-round-register_globals/ Share on other sites More sharing options...
revraz Posted December 12, 2008 Share Posted December 12, 2008 What variable doesnt work, $submit_button, $pagerName or $pagerPhone? Link to comment https://forums.phpfreaks.com/topic/136679-get-round-register_globals/#findComment-713683 Share on other sites More sharing options...
simonp Posted December 12, 2008 Author Share Posted December 12, 2008 What variable doesnt work, $submit_button, $pagerName or $pagerPhone? not really sure! What I don't get is how PHP knows what any of them are as they are passed from a form?? Link to comment https://forums.phpfreaks.com/topic/136679-get-round-register_globals/#findComment-713685 Share on other sites More sharing options...
rhodesa Posted December 12, 2008 Share Posted December 12, 2008 http://us2.php.net/manual/en/function.import-request-variables.php but that is not recommended. instead, assign variables that you want: $submit_button = $_POST['submit_button']; Link to comment https://forums.phpfreaks.com/topic/136679-get-round-register_globals/#findComment-713686 Share on other sites More sharing options...
Yesideez Posted December 12, 2008 Share Posted December 12, 2008 You can pass session variables from one page to another. Place session_start() at the start of each file that uses them. http://www.tizag.com/phpT/phpsessions.php Link to comment https://forums.phpfreaks.com/topic/136679-get-round-register_globals/#findComment-713694 Share on other sites More sharing options...
simonp Posted December 12, 2008 Author Share Posted December 12, 2008 but that is not recommended. instead, assign variables that you want: $submit_button = $_POST['submit_button']; This worked a treat - I knew it was something simple Thanks all. Simon Link to comment https://forums.phpfreaks.com/topic/136679-get-round-register_globals/#findComment-713706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.