Help with multi form pages :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Help with multi form pages :(

Post by JPlush76 »

I have a page I made for a user to edit their account.. they can:
edit their billing address
edit their shipping
and edit their password

I used the same page for all three and just use a GET variable to do a SWITCH statement with.

IE to edit your password the link is: myedit?do=editpass

well everything works fine with register globals OFF, but when I upload it to my live server (which I can't touch) the globals are ON and it doesn't work, the URL goes blank, I've also turned my globals on locally and it fails as well... any thoughts?


When I hit submit with globals OFF url =
http://localhost/fs/sc_myedit.php?do=editpass

When I hit submit with globals ON =
http://localhost/fs/sc_myedit.php
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

so I'd read the file like this

Code: Select all

<?php
switch ($_GETї'do']){

// IF THE USER WANTS TO EDIT THEIR ACCOUNT INFORMATION
case "editpass":
?>

<form action="<?=$PHP_SELF?>"  method="POST">

<INPUT TYPE="hidden" NAME="formcode" VALUE="editpass_done">

	<table width="70%" border="0" cellspacing="0" cellpadding="2">
                              <tr> 
                            <td align="right"></td>
                            <td> 
                             <B>Change My Password</B>
                            </td>
                          </tr>
						  <tr> 
                            <td align="right">Old Password:</td>
                            <td> 
                              <input type="password" name="f_oldpass" size="15" maxlength="15">
                            </td>
                          </tr>
						   <tr> 
                            <td align="right">New Password:</td>
                            <td> 
                              <input type="password" name="f_newpass1" size="15" maxlength="15">
                            </td>
                          </tr>
						  <tr> 
                            <td align="right">Confirm New Password:</td>
                            <td> 
                              <input type="password" name="f_newpass2" size="15" maxlength="15">
                            </td>
                          </tr>
                        
						  <tr>
                            <td align="right"></td>
                            <td>
                             <input type="submit" name="Submit" value="Change Password">
                            </td>
                          </tr>
                        </table>
	<!-- END EDIT SHIP -->
	
	</form>





<?php
// END OF ACCOUNT EDIT
break;
?>
and when I hit submit, at the top of the page I check the formcode variable to see which form to process
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

The page "Predefined variables" in the PHP Manual says:

Code: Select all

Warning

In PHP 4.2.0 and later, the default set of predefined variables which are available in the global scope has changed. Individual input and server variables are by default no longer placed directly into the global scope; rather, they are placed into the following superglobal arrays.

You can still force the old behaviour by setting register_globals to 'On' in your php.ini file.

For more information and background on this change, please see the PHP 4.1.0 Release Announcement.
And additionally:

Code: Select all

$_GET

Variables provided to the script via HTTP GET. Analogous to the old $HTTP_GET_VARS array (which is still available, but deprecated).
My comment:
Maybe your "live server" has an older PHP version than you?
Maybe it does not understand "$_GET"? It might believe that "$_GET" is just a variable like "$MyCounter" or "$StrHTMLOutBuffer".

Try uploading a page that uses the predefined array "$HTTP_GET_VARS" instead, and "$HTTP_POST_VARS" accordingly.
Post Reply