Jump to content

PHP4 to PHP5 Script Conversion


mattd8752

Recommended Posts

I wrote a simple script on my PHP4 server, and for some reason it is not working on my PHP5 server.

 

Could anyone take a look at what needs to be changed.

 

I am running php5.1.6 on my new server.  If you need to see a phpinfo it is directly on mattdsworld.com

 

I can't figure out what I need to change.  This is the page source:

<?php
include "xml.php";//Change this to your XML page
$xml = new Xml;
$a = $xml->parse("admin.xml");

$run = FALSE;
include "encrypt.php";//Change this to your encrypt page
$run = TRUE;

if(!isset($_POST['username'])){
?>
<div align=center>
<form action="index.php" method="post">
<b>Username</b>:<input type="text" name="username" size="20"><br>
<b>Password</b>:<input type="password" name="pw" size="20"><br>
<input type="submit" value="Login"></form></div>
<?php
}else{
session_start();


if(isset($a[$_POST['username']])){


if($run == TRUE){


$crypt = $a[$_POST['username']][password];
$ret = compare($_POST['pw'],$crypt);
if($ret == FALSE){
?>

<div align=center><b>Oops! Your login is wrong. Please click back and try again.</b><br>
<form action="index.php" method="post">
<b>Username</b>:<input type="text" name="username" size="20"><br>
<b>Password</b>:<input type="password" name="pw" size="20"><br>
<input type="submit" value="Login"></form></div>

<?php
}else{
$login_username=$_POST["username"];
session_register("login_username");
Header("Location: protected.php");
}


}else{
if(md5($_POST['pw']) == $a[$_POST['username']][password]){
$login_username=$_POST["username"];
session_register("login_username");
Header("Location: protected.php");
}else{
?>

<div align=center><b>Oops! Your login is wrong. Please click back and try again.</b><br>
<form action="index.php" method="post">
<b>Username</b>:<input type="text" name="username" size="20"><br>
<b>Password</b>:<input type="password" name="pw" size="20"><br>
<input type="submit" value="Login"></form></div>

<?php
}
}





}else{
?>
<div align=center><b>Oops! Your login is wrong. Please click back and try again.</b><br>
<form action="index.php" method="post">
<b>Username</b>:<input type="text" name="username" size="20"><br>
<b>Password</b>:<input type="password" name="pw" size="20"><br>
<input type="submit" value="Login"></form></div>
<?php
}



}
?>

 

Normally this would redirect you to the correct page if the password is correct.  Now it shows the top form.

 

If the password is wrong it still does error handling though if the username or password is wrong.  Please try to find the problem if you don't mind.

 

I have tried many changes.

Link to comment
https://forums.phpfreaks.com/topic/43269-php4-to-php5-script-conversion/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.