Jump to content

Recommended Posts

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?

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012438
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012441
Share on other sites


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.

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012443
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012446
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012447
Share on other sites

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.)

Link to comment
https://forums.phpfreaks.com/topic/192106-funny-php-problem/#findComment-1012517
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.