GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Nov-2005, 18:47
fallen_samurai fallen_samurai is offline
Awaiting Email Confirmation
 
Join Date: Oct 2005
Location: Wisconsin, USA
Posts: 29
fallen_samurai is on a distinguished road

if statement variable problem


I have a script that sets a variable inside of an if statement coming from a post-type forum. I'll try to condense the script to show what I mean. *NOTE: I ignored the full form context for the purpose of making the condensed version.

PHP Code:

if (!$_GET['act']) { <form><select name="div"></select></form> }
else {
if ($_GET['s'] == '1') { //Step 1
$div = $_POST['div'];
// This part of the script pulls what option the person selected inside of the 'div' dropdown box. Then it prints a dropdown of all the usernames that belong to that 'div'. This part works.
}
if ($_GET['s'] == '2') { //Step 2
$username = $_POST['username'];
//This part selects the username then pulls a list of ranks to promote the person to and puts them in a dropdown box. Herein lies the error.
} 



Step 1 Returns:
Quote:
Division Chosen:
Guild Wars
Choose a User:
[dropdownbox]

Step 2 Returns:
Quote:
Division Chosen:

User Chosen:
test
Promote/Demote to:
[dropdownbox]

For some reason the $div variable doesn't work anymore, or it gets erased after the first step if statement ends. I can't figure out why it won't show up in step two. Can anyone help me with this?
  #2  
Old 22-Nov-2005, 07:32
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: if statement variable problem


I really don't understand the problem but I suggest something...

If $_POST['div'] is set in either step, the setting should happen outside the ifs

PHP Code:

$div = false;
if( isset($_POST['div']) && $_POST['div'] )
  $div = _some_data_screening_function( $_POST['div'] );

// the IFs
if ($_GET['s'] == 1) { //Step 1

}
if ($_GET['s'] == 2) { //Step 2  

} 


 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 4) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
[Tutorial] Pointers in C (Part II) Stack Overflow C Programming Language 0 27-Apr-2005 17:36
Need a bit of help with switch() Caibre C Programming Language 5 12-Apr-2005 17:02
editbox output problem FireFox8173 MS Visual C++ / MFC Forum 1 01-Apr-2005 14:15

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:51.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.