PHP4 to PHP5

liunx

Guest
Hi,
I am a sys admin trying to upgrade existing a Linux server. With this upgrade I am also upgrading PHP/mysql. PHP4 to PHP5 and mysql 4.x to 5.0.22. I have code written code written under PHP4. It was written by a different developer. Now the same code I am trying under PHP5, which does not work. Below is the code which was written under PHP4. I am very new PHP. After goolging I found out that "register_globals = Off" was causing the problem. I did manage to modify some smaller PHP code, which worked. Can someone help with what to modify with the below code to comply with PHP5?



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <body> <center><a href=http://www.phpbuilder.com/board/archive/index.php/"index.html">Home</a> |
<a href=http://www.phpbuilder.com/board/archive/index.php/"add.html">Create New Customer</a> |
<a href=http://www.phpbuilder.com/board/archive/index.php/"search.html">Subscribe Existing Customer</a> |
<a href=http://www.phpbuilder.com/board/archive/index.php/"search.html">Change Customer Info</a> |
<a href=http://www.phpbuilder.com/board/archive/index.php/"search.html">Search Customer Database</a> </center> <?php require("modules/config.inc"); require("modules/functions.inc"); // Actions....
if(! $customerid) {
echo "Error: No record to update. Please go to the
<a href=http://www.phpbuilder.com/board/archive/index.php/\"search.html\">Search</a> page to find the
customer record to update<P>\n";
exit;
}
if($action == "update_user")
{
include("modules/update_user_errorcheck.inc");
}
else {
echo '<form method="post">';
echo '<input type=hidden name=action value=update_user>';
include("modules/retrieve_custinfo.inc");
include("modules/update_form.inc");
include("modules/retrieve_subscription.inc");
?>
<br clear="all"><br><table align="center"><br>
<tr align="center"><td colspan="4"><br>
<input type="submit" value="Modify Customer"><br>
</td></tr></table><br>
<br><hr><br><br>
<?php
echo '</form>' . "\n";
}
?>
</BODY>
</HTML>


Thanks in advance.There's nothing in that page to change except for replacing $action with $_POST['action']; all the problems must be in those ".inc" files. Where they mention $update_user, and whatever variables named after other form fields those includes mention should be changed similarly.

Putting extract($_POST) at the top of that page may be suggested, but it should only be regarded as a dirty patch designed to get it working while you take the time to do it properly.

And I'd point out that this isn't specifically a PHP5 issue: if this code is anything less than about four or five years old (depending on how you count it) then it was badly written in the first place :).
 
Back
Top