943,748 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1112
  • PHP RSS
Sep 4th, 2008
0

URL Variables PHP4 to PHP5

Expand Post »
Hi, I've been working with PHP for about 6 or 7 years now, and recently I came across a problem that I really couldn't figure out.

At my work, we have management software that has been worked on for years and years by a lot of different programmers. It is completely written in PHP3 and PHP4 and is not object-oriented. Recently, we bought a new Mac Pro to act as our new server, as our servers were very old. I loaded it up with Ubuntu 8.04, PHP5, and MySQL only to find that the old code wouldn't work in PHP5. As I would love to keep PHP5 on the system and not resort to using PHP4, I'm looking for a fix to the primary problem I've found throughout the code.

The problem is this:
php Syntax (Toggle Plain Text)
  1. $res = sql("SELECT * FROM users WHERE login='$login' AND pass='$pass' AND retired=0");

The two variables are not declared anywhere else in the page. The variables are used to retrieve POST variables from this form:
html Syntax (Toggle Plain Text)
  1. <html>
  2. <head><title>Login screen</title>
  3. <link rel="stylesheet" type="text/css" href="style.php">
  4. </head>
  5. <body bgcolor="#ffffff" text="#000000">
  6. <form name="login" action="do_login.php" method="post">
  7. <table border=0 cellspacing=5 cellpadding=5>
  8. <tr>
  9. <td align="right" bgcolor="#eeeeee"><b>Login name</b>&nbsp;</td><td><input type="text" name="login" size="20" maxlength="15" value=""></td></tr>
  10. <tr>
  11. <td align="right" bgcolor="#eeeeee"><b>Password</b>&nbsp;</td><td><input type="password" name="pass" size="20" maxlength="15"></td></tr>
  12. <tr>
  13. <td colspan=2 align="center" bgcolor="#eeffee"><input type="submit" value="Login"></td></tr>
  14. </table>
  15. <br>
  16. <br>
  17. </body>
  18. </html>

Even back when I started to teach myself PHP, I never did form variables this way. It seems to work in PHP3 and 4, but certainly not PHP5. Now my question is: Is there a setting in php.ini that I could set to make this work without any coding changes? The software seems to have this problem everywhere, and it is MASSIVE. It would take me months to fix all of the variables.

Thanks in advance,
MVied

Oh, and for the record, I had nothing to do with this terrible coding. I was just hired after these guys to fix their messes.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
Sep 4th, 2008
0

Re: URL Variables PHP4 to PHP5

Just use $_POST to get it work

$login = $_POST["login"];
$pass = $_POST["pass"];

I am sure you must be knowing this. Now in PHP.ini you have some option i dont remeber something like register_globals and if thats on then you get all form variables directly into your form. THis is not safe and for production servers it should be always off.
Reputation Points: 11
Solved Threads: 2
Junior Poster
einfoway is offline Offline
145 posts
since Nov 2005
Sep 4th, 2008
0

Re: URL Variables PHP4 to PHP5

Well I know that's what I should do, but I 'm really trying to save myself some time here. The entire piece of software weighs in at 100MB of PHP. The site is heavily based on frames and forms and literally every page opened uses GET or POST variables. Everytime they're used in the scripts, they are declared incorrectly and will not work in PHP5. I'm just looking for a way around change every single page. It would literally take me weeks.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
Sep 4th, 2008
0

Re: URL Variables PHP4 to PHP5

then try using register_global = on
Reputation Points: 11
Solved Threads: 2
Junior Poster
einfoway is offline Offline
145 posts
since Nov 2005
Sep 4th, 2008
0

Re: URL Variables PHP4 to PHP5

Insecure, but it worked. I swear, the people that coded this were terrible.

Thanks for the help!
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php table export excel worksheet decimal places problem
Next Thread in PHP Forum Timeline: Personal Account Page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC