Solved

PHP form issue

Posted on 2012-03-13
15
208 Views
Last Modified: 2012-03-16
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
Comment
Question by:nachtmsk
  • 8
  • 6
15 Comments
 
LVL 30

Expert Comment

by:IanTh
ID: 37714958
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37715496
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
 

Author Comment

by:nachtmsk
ID: 37715639
Ray - thanks.
Unfortunately the other box is offline so I am just left this this new box  :(
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37715656
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
 

Author Comment

by:nachtmsk
ID: 37715690
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
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37715735
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
 

Author Comment

by:nachtmsk
ID: 37715924
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37715972
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
 

Author Comment

by:nachtmsk
ID: 37716016
@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
 

Author Comment

by:nachtmsk
ID: 37716037
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37716048
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37716066
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37716079
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
 

Author Comment

by:nachtmsk
ID: 37729579
@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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37731467
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now