patricia3d Posted February 15, 2010 Share Posted February 15, 2010 I am an old Linux/Php/Mysql User. I have an old Linux Databaes server. Today I got a New server with Fully Loaded Linux/Php/Mysql. I have to transfer my Old PHP Script and Databases to New Server. I have transferred All the Data, but my Old PHP Scripts are not working in the New server. I have a small script for you to understand the problem. See this Code. <html> <body> <? echo "<br>mname=$mname<br>"; ?> <form method='POST' action='n.php'> <input type='text' name=mname> <input type='submit' name ='sub'> </form> </body> </html> Its working in Old Server. Name of the Php file is n.php Its calling itself with <form method=post action='n.php>. In the Old server is working fine and showing the name which is given as input when submitted. but in the new server its working and accepting the name and showing nothing when its called by itself using action. I don't know what to do? Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/ Share on other sites More sharing options...
Deoctor Posted February 15, 2010 Share Posted February 15, 2010 I think in the php.ini of the new server you dont have the short_open_tag on. so this could be giving the problem.. just check that.. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012436 Share on other sites More sharing options...
ToonMariner Posted February 15, 2010 Share Posted February 15, 2010 it could also relate to the register globals setting - which is probably ON on your old server and OFF (like it should be) on you new server... check the short open tag thing first and if no joy have a look at register globals. try putting $mname = $_GET['mname']; // or $_POST['mname'] or where ever you are getting it from. above that code you posted.. If it then works the register globals is you 'problem' Rather than turn it ON you should go and initialize your variables in EVERY script you have that requires it. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012438 Share on other sites More sharing options...
patricia3d Posted February 15, 2010 Author Share Posted February 15, 2010 Thanks for reply. I have checked up in my Both servers old and new that short_open_tag = On but even the problem exists. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012440 Share on other sites More sharing options...
patricia3d Posted February 15, 2010 Author Share Posted February 15, 2010 Thanks for reply. I have checked up in my Both servers old and new that short_open_tag = On but even the problem exists. Thanks Toon this can be done, but I have about 300 php scripts and each script some time 10 to 20 <input> tages are used. It will take days to convert all my php scripts. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012441 Share on other sites More sharing options...
Maq Posted February 15, 2010 Share Posted February 15, 2010 if(isset($_POST['sub'])) { echo " mname={$_POST['mname']} "; } ?> </pre> <form method="'POST'" action="'<?php">'> </form> <br><b A few issues: 1) Using short open tags is highly discouraged. 2) When submitting to the same page you should use the safer reserved variables PHP_SELF. 3) Seems as though you're utilizing global variables which have been turned off a while ago due to security reason. If you're using POST or GET use them respectively when submitting in forms. 4) You should also check to see if the 'sub' button was pressed with the isset function, to avoid empty variables. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012443 Share on other sites More sharing options...
patricia3d Posted February 15, 2010 Author Share Posted February 15, 2010 it could also relate to the register globals setting - which is probably ON on your old server and OFF (like it should be) on you new server... Thanks Thanks ToonMariner. Its working now.. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012445 Share on other sites More sharing options...
Maq Posted February 15, 2010 Share Posted February 15, 2010 it could also relate to the register globals setting - which is probably ON on your old server and OFF (like it should be) on you new server... Thanks Thanks ToonMariner. Its working now.. Did you turn registered globals on? If you did, that's a very poor solution... They should never be relied on and in fact, were deprecated as of PHP 5.3. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012446 Share on other sites More sharing options...
Deoctor Posted February 15, 2010 Share Posted February 15, 2010 it could also relate to the register globals setting - which is probably ON on your old server and OFF (like it should be) on you new server... Thanks Thanks ToonMariner. Its working now.. Check this post before turning the global variables on http://roshanbh.com.np/2008/02/register_globals-php-security-problem.html Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012447 Share on other sites More sharing options...
PFMaBiSmAd Posted February 15, 2010 Share Posted February 15, 2010 Since register_globals have been completely removed in php6, now would be the time to start updating your code to use the correct $_POST, $_GET, $_COOKIE, $_FILES, $_SESSION, $_SERVER, and $_ENV... variable where the data is actually coming from. Register_globals were turned off by default in php4.2 in the year 2002, almost 8 years ago, and finally throw a depreciated error in php5.3 when they are found to be turned on. It is sad that we are still seeing people experiencing problems with their code at this point in time. All code and web hosting that relied on register_globals or had them turned on should have been updated long long ago (8 years in software 'time' is like a couple of decades in human time.) Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012517 Share on other sites More sharing options...
PFMaBiSmAd Posted February 15, 2010 Share Posted February 15, 2010 I have about 300 php scripts Wow. That kind of missed the point of using a server-side scripting language to reduce the amount of code and work necessary to create and maintain a site. Quote Link to comment https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012535 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.