Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2008-01-04, 10:08 PM
Junior Member
 
Join Date: Jan 2008
Posts: 1
donh is on a distinguished road
Default Convert script from PHP 4 to PHP 5

Hello all,
I have a script that was written on PHP 4, it uses Globals On. Now that I have moved to PHP 5 my script no longer works.

I know that in PHP 4 Globals was on. In PHP 5 Globals is Off by default.

I could override using a php.ini file in the directory, but this is a hack and does not fix the problem.

I know what the problem is, but can't for the life of me figure out how to correct it for PHP 5 and Globals Off. The script has a password field and then if correct logs in the user. If not the error is given.

So... I know I need to update the syntacs but I have no idea what to do here. If I can get some help on thi spart, I can then correct the rest of the script.

The variable $adpasswd is set and pulled from the config.php file. A form is used to login and checks against the config.php to see if the password is correct. If it is you login, if not the error is shown.

Thank you ahead of time for your help.

Here is the part in question:

Code:
session_start();
include("templates/header.tpl");
include("config.php");

if(!isset($adminuser)){
if(!isset($action)){
include("templates/login.tpl");
}else{
if($adminpass != $adpasswd){
include("templates/login.tpl");
echo "<table width='100%' border='0' cellspacing='3' cellpadding='3'><tr><td class='message_error' align='center'>Invalid Password, Please Try Again!</td></tr></table>";
}else{
$adminuser = "yes";
session_register('adminuser');
$action = "loggedin";
}
}
}

if(isset($adminuser)){
dbconnect();
include('templates/menu.tpl');

if($action == "loggedin"){
$message = "<tr><td><table width='100%' border='0' cellspacing='3' cellpadding='3'><tr><td class='message_error' align='center'>Hello $contact_name! Nice to see you again. Use the menu above to navigate EzBan.</td></tr></table>";
$msg = $message;
echo $msg;
}

Last edited by donh; 2008-01-05 at 01:51 AM.
Reply With Quote
  #2 (permalink)  
Old 2008-01-06, 12:33 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

Actually register_globals has been off in PHP 4 for a very long time. Since 4.0.6, so I assume this is a very old version of 4 you upgraded from.

Basically, you have tell the script where the variables are coming from. $_COOKIE, $_GET, or $_POST.

There are some scripts out there that will auto convert as if globals were still on, but i wouldnt use them as it makes your stuff all sorts of insecure.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:15 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.