0

I am upgrading some very old code to PHP 5.6 - I am having trouble getting the login form to work.

I have edited out as much superfluous code as I can to keep it simple but basically the present form looks like this:

<?    if (isset($_POST["state"])){ //1      ?>        
    <form name="psinput" method="post" action="login.php">
        <input type="text" name="pseudo">
            <input type="password" name="password">
                <input type="password" name="password2">
                <input type="hidden" name="state" value="1">
                      <input type="image"  name="imageField" src="../images/join_button.gif">
                        <?  }
elseif ($state == 1) {    
if ($password != $password2){
    $errormess = "Your passwords do not match";
    }
else if (strlen($pseudo) == 0){
    $errormess = "Please enter a pseudonym";
    }
else if ($pseudo == $password){
    $errormess = "Your pseudonym cannot be the same as your password";
    }
else if (strlen($password) == 0){
$errormess = "Please enter a pseudonym password";
    }
    }

And then there is a bunch of stuff that happens (insertion into the database etc) and if it all goes well it spits out the text:

            print "Your pseudonym and password have been created<br><br>";

However when I hit the submit button on the form, it just returns the empty form to me again. I believe the problem to be with the way the state variable is being handled. I sincerely hope I have provided enough data for this question.

Patrick Lee
  • 1,990
  • 1
  • 19
  • 24
D Rice
  • 71
  • 9
  • 2
    if your older version of PHP relied on register globals http://php.net/manual/en/security.globals.php (http://stackoverflow.com/questions/3593210/what-are-register-globals-in-php), then you will need to assign your variables to POST arrays. Use error reporting http://php.net/manual/en/function.error-reporting.php see also http://php.net/manual/en/tutorial.forms.php - Plus, you may no longer be able to use `mysql_` functions if you are using those and will need to use `mysqli_` or PDO. Error reporting will tell you that also; deprecation notice. What's your old version number of PHP? – Funk Forty Niner Jan 03 '16 at 00:34
  • Hi Fred, I was using PHP 4 I believe - and I have full error reporting turned on, but the page is reporting no errors, just returning me an empty form when I hit submit. – D Rice Jan 03 '16 at 00:38
  • 5.6 should have short tags enabled by default. But if not, try changing `` to ` – Funk Forty Niner Jan 03 '16 at 00:40
  • I also don't see a closing `` tag. So, if it's in there and part of your *"superfluous code"*, you'll need to show us more code and the SQL also. A missing closing form tag will also cause havoc. – Funk Forty Niner Jan 03 '16 at 00:44
  • Sorry Fred - it's just that this script is 697 lines long. I didn't figure anyone wanted to wade through that much code. Yes, there is an ending . Thanks. – D Rice Jan 03 '16 at 00:48
  • Can u share yur submission code from php – devpro Jan 03 '16 at 03:02
  • I would love to, but apparently it's 958 characters too long! – D Rice Jan 03 '16 at 20:08

0 Answers0