[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

PHP form issue

Hi,
I'm tracking through someone elses code.  
I have a form page, it's supposed to login to a database and bring back some user info.
This was working fine on a previous Linux box. I recently moved the code over to a new box and I'm having problems getting the login to work.
What happens when I press on the "Login" button (See attached) is the page just refreshes and the login info in the input boxes disappears. No errors anyplace. I have verified that PHP is up and running on my new box (I have other php pages that work fine on other sites).
I'm thinking I either 1. Missed something really simple in the move or 2. There is some incompatibility with my current box/version/etc...  The OS on both boxes is RedHat, albeit a newer version on this current box.

I'm putting 'echos' thoughout the code to see where I get.
In this snip below, I get into the " if(!$this->FormSubmitted line 105)  which I'm thinking is saying my Form isn't being submitted but I don't know how/why I would get here.  I'm assuming I should be getting down past this line and to line 109.

Any ideas? Thanks so much.
Nacht
here is the code where this happens:



//Operation Method @2-3942470C
     96     function Operation()
     97     {
     98         if(!$this->Visible)
     99             return;
    100 
    101         global $Redirect;
    102         global $FileName;
    103 
    104         if(!$this->FormSubmitted) {
    105 echo 'I am here but should I be';
    106             return;
    107         }
    108 
    109         if($this->FormSubmitted) {
    110             $this->PressedButton = "Button_DoLogin";
    111             if(strlen(CCGetParam("Button_DoLogin", ""))) {
    112                 $this->PressedButton = "Button_DoLogin";
    113             }
    114         }
    115         $Redirect = $FileName;
    116         if($this->Validate()) {
    117             if($this->PressedButton == "Button_DoLogin") {
    118                 if(!CCGetEvent($this->Button_DoLogin->CCSEvents, "OnClick")) {
    119                     $Redirect = "";
    120                 }
    121             }
    122         } else {
    123             $Redirect = "";
    124         }
    125     }
    126 //End Operation Method

Open in new window

0
nachtmsk
Asked:
nachtmsk
  • 8
  • 6
1 Solution
 
IanThCommented:
is it using the same version of php

try copying the code and start fresh php file and copy in the contents and see if that helps
0
 
Ray PaseurCommented:
Suggest you run phpinfo() on both installations and compare the output line-for-line.  Many "little things" like magic quotes and register globals can trip up a move from one machine to another.  It may also be worth refactoring this code.  The use of "global" declarations inside a function is not a very good design paradigm.

If you're looking for PHP authentication, you might find some good ideas in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html
0
 
nachtmskAuthor Commented:
Ray - thanks.
Unfortunately the other box is offline so I am just left this this new box  :(
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Ray PaseurCommented:
Is this on a public facing computer?  If so, please post a URL so we can take a look a the phenomenon in action.  Maybe we can spot something or at least suggest some debugging steps.
0
 
nachtmskAuthor Commented:
Ray .. yep.
here is the URL. Click on the link it provides. Try to login with anything. It should return an error message with an incorrect login but it returns back to itself.

http://www.ipopregister.com/

You will see some var_dump outputs at the top of the page ;)

Thanks!
Nacht
0
 
Ray PaseurCommented:
Suggest you add this right at the top of Login.php.  The code might not need to email this information.  It might be OK to print it right on the page, but there is a risk that starting browser output too early may break the cookies, and thus break the session.  A safe way to test this would be to remove everything from line 12 on down.
error_reporting(E_ALL);

// OPEN AN OUTPUT BUFFER
ob_start();

// SHOW THE SUPERGLOBALS
echo PHP_EOL . "GET ";   var_dump($_GET);
echo PHP_EOL . "POST ";  var_dump($_POST);
echo PHP_EOL . "COOKIE ";var_dump($_COOKIE);
echo PHP_EOL . "SESSION ";var_dump($_SESSION);

// CAPTURE THE BUFFER
$vardump = ob_get_clean();

// SEND THE RESULTS
mail('You@Your.org', 'VARDUMP', "$vardump");

Open in new window

0
 
nachtmskAuthor Commented:
Ray..
Thanks, I put that code in. If you are looking at the page you will see the output up top.
It's telling me that the username and password are being passed. I'm not sure where it's dying though.
I'm thinking the problem must be something more overall then this because it was working fine on the older box.
Question--- do certain ENV vars need to be set in order to make PHP work?
Did I mention I'm not really a PHP programmer -- I'm more C and Perl.

Thanks!
Nacht
0
 
Ray PaseurCommented:
Any chance you can get the old box back online, even for a moment?  What you would really like to do is run this script on both of them and compare the output line-for-line.
<?php phpinfo();

Open in new window

The short answer about the ENV vars is, "Yep there are things that matter in the PHP environment."

If you cannot get both of the boxes operational so you can compare the PHP environments, please install that script on the new box and post a link to it.  You can take it down later - I would just like to see what's in the new configuration.  Maybe it will suggest something.
0
 
nachtmskAuthor Commented:
@Ray,
No chance on the old box, it's wiped.
Here is php.info
http://www.ipopregister.com/info.php

Thanks SO much for this help.

Nacht
0
 
nachtmskAuthor Commented:
I'm really thinking it must be some global server thing I'm missing.
Gotta run out now. Thanks for all your help. I'll check back on this later this afternoon.
Nacht
0
 
Ray PaseurCommented:
This is a guess, but should be easy enough to test.  Try using php.ini to turn these two directives on.
register_argc_argv      On
register_globals      On

To see why that might matter, have a look at this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html
0
 
Ray PaseurCommented:
You might consider turning this on, too.  Not sure about that part, but it might matter.
magic_quotes_gpc  On

It's another one of those old, bad ideas from the early days of PHP.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6630-Magic-Quotes-a-bad-idea-from-day-one.html
0
 
Ray PaseurCommented:
And this will probably cause something to belch out a lot of notices, but the answer may appear among the notices.  Add this line to the top of the login script.
error_reporting(E_ALL);

Open in new window

0
 
nachtmskAuthor Commented:
@Ray -- just a comment. I think I found the problem I've been having all week.
In my php.ini file  register_long_arrays was set to Off. I set it to On and everything started working. I'm guessing I should go ahead and replace all of my HTTP_*VARS variables.
I still have some questions I will be posting as other questions. Thanks again for the help.
0
 
Ray PaseurCommented:
replace all of my HTTP_*VARS variables

Yep.  For the most part they are no longer something that makes sense, and are mostly deprecated.  Switching to use the superglobals is the right way to go.
http://php.net/manual/en/language.variables.superglobals.php
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now