Solved

PHP form issue

Posted on 2012-03-13
15
206 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
@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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
@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
Comment Utility
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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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…

762 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

12 Experts available now in Live!

Get 1:1 Help Now