Solved

PHP form issue

Posted on 2012-03-13
15
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 110

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 110

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 110

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
 
LVL 110

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 110

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 110

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 110

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 110

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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 how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 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