Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2006, 10:40 PM
who is chris c who is chris c is offline
 
Join Date: Sep 2005
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default variable passing

i'm having a stupid moment here and cant figure out why the variables arnt passing
PHP Code:
if(!$step){$step=1;}

  if((
$step1 == 1) && ($agree == yes)){ header("/signup.php?step=2"); }
elseif((
$step1 == 1) && ($agree != yes)){ header("/signup.php?warn=yes"); }
elseif((
$step2 == 1) && ($agree == yes)){ header("/signup.php?step=3"); }
elseif((
$step2 == 1) && ($agree != yes)){ header("/signup.php?step=2&warn=yes"); } 

PHP Code:
         <form method="post" action="signup.php">
         <?if($warn==yes){?><b><?}?>In order to proceed, you must agree with the following Terms of Service:</b>
         <table width="100%">
          <tr>
           <td colspan="2">
           <div style="border:thin inset;background: #000022; padding:6px; height:175px; overflow:auto"><?=$html[1]?></div>
           </td>
          </tr>
          <tr>
           <td><input type="checkbox" name="agree" value="yes" style="background: #111111;"> <input type="hidden" name="step1" value="1"> <strong><nobr>I have read, and agree to abide by the Terms of Service.</nobr></strong></td>
           <td align="right"><input type="submit" value="next >>"></td>
          </tr>
         </table>
         </form>
that should be all i need to paste either its been too long since i've done any programming or i'm just an idiot either way its too hard getting back into things from a yr vacation
Reply With Quote
  #2  
Old 10-02-2006, 06:53 AM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try

header("Location: /signup.php?step=2");

EDIT:

Also, on a sidenote, you don't need the brackets {} if you only want to do one thing. So instead of
PHP Code:
if(!$step){$step=1;} 
You can simply do this
PHP Code:
if(!$step$step=1

EDIT 2:

There should be quotes around the "yes".
PHP Code:
$agree == 'yes' 
Reply With Quote
  #3  
Old 10-02-2006, 07:37 AM
Guest190829
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by nico_swd
Try

header("Location: /signup.php?step=2");

EDIT:

Also, on a sidenote, you don't need the brackets {} if you only want to do one thing. So instead of
PHP Code:
if(!$step){$step=1;} 
You can simply do this
PHP Code:
if(!$step$step=1
EDIT 2:

There should be quotes around the "yes".
PHP Code:
$agree == 'yes' 
You can also use the switch statement, which in my personal opinion is alot cleaner than a bunch of if/elseif statements:

http://us3.php.net/switch
Reply With Quote
  #4  
Old 10-02-2006, 07:49 AM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep, I prefer the switch() method as well. In his case he could do something like this:
PHP Code:

$case 
$step $agree;

switch (
$case)
{
     case 
'1yes':

            
header("Location: /signup.php?step=2");
            break;
     
     default:
     case 
'1no':

            
header("Location: /signup.php?warn=yes");
            break;

     
// And so on...
}

exit(); 
Reply With Quote
  #5  
Old 10-02-2006, 07:54 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just another simpler (IMO) variation...
PHP Code:
switch (true)
{
    case (
$step == and $agree == 'yes'):
        
header('Location: /signup.php?step=2');
        break;

Your way is neat... I've never seen people do it like that.
Reply With Quote
  #6  
Old 10-02-2006, 08:04 PM
who is chris c who is chris c is offline
 
Join Date: Sep 2005
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for the help so far but that didnt fix the problem i'm having its either not setting the values in
HTML Code:
 <td><input type="checkbox" name="agree" value="yes" style="background: #111111;"> <input type="hidden" name="step1" value="1"> <strong><nobr>I have read, and agree to abide by the Terms of Service.</nobr></strong></td>
           <td align="right"><input type="submit" value="next ->"></td>
because $stepx (where step is 1 or 2) and $agree arnt setting it seems put the 2 vars at the top just echoing them before the if/switch(have it wrote both ways) but they arnt echoing anything so they arnt set not sure whats going on
Reply With Quote
  #7  
Old 10-02-2006, 08:20 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is the code you posted above the beginning of your page? If so, do you have register globals enabled? Try either changing all $step to $_POST['step'] and $agree to $_POST['agree'], or try placing this at the top of your page.
PHP Code:
extract($_POST); 
You can also try this to see which POST variables are received in this page.
PHP Code:
print_r($_POST); 
If this outputs an empty array, then does your form fail.
Reply With Quote
  #8  
Old 10-02-2006, 09:08 PM
who is chris c who is chris c is offline
 
Join Date: Sep 2005
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

changing it to $_POST helped now i get the values: Array ( [agree] => yes [step1] => 1 [step] => 1 ) so they are stored and the switch is working just not liking
PHP Code:
switch (true)
{
    case (
$_POST['step1'] == and $_POST['agree'] == 'yes'):
echo 
"almost";        
header('Location: /signup.php?step=2');
echo 
"!!!!your here!!!!!";
        break;

the redefinition of the header: header('Location: /signup.php?step=2');
due to it already defined in the include
Reply With Quote
  #9  
Old 10-02-2006, 09:33 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You cannot modify the header information after outputting data to the browser. Take out the first echo and it should work.
Reply With Quote
  #10  
Old 10-02-2006, 10:05 PM
harmor19 harmor19 is offline
 
Join Date: Apr 2005
Posts: 1,324
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Couldn't you write a function as well?


You can put the function at the top of your script, below the opening php tag.
PHP Code:
function checkValues($step$agree$page);
{
    if(
$step == && $agree == "yes")
    {
        
header('Location: ?step=$page');
    }
    else
    {
       
header('Location: ?step=$page&warn=yes');
    }


Where you're using the if/else or switch method you can replace it with
PHP Code:
checkValues($_POST['step1'], $_POST['agree'], $_POST['page']) 
In your first form add the HTML code below the opening form tag.
HTML Code:
<input type="hidden" name="page" value="1" />
Add the same HTML code to all the other forms but change "value="1"" to "value="2"" and value="3"".
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:44 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04460 seconds
  • Memory Usage 2,296KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_html
  • (15)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (9)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete