SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    help , if id=1 open xxx.php , if id=2 open xxx.php ....

    hello all. i need some form , for example:



    if type "test1" open ?step=2 and info for test1
    if type "test2" open ?step=2 and info for test2
    if type "test3" open ?step=2 and info for test3


    this my code now

    PHP Code:
    <?PHP 

    // start the session 
    session_start(); 
        

    if(isset(
    $HTTP_POST_VARS['step'])) 

        
    $smolf3d['step'] = $HTTP_POST_VARS['step']; 

    elseif(isset(
    $HTTP_GET_VARS['step'])) 

        
    $smolf3d['step'] = $HTTP_GET_VARS['step']; 

    else 

        
    $smolf3d['step'] = '1'


    if(!isset(
    $step) || $step == 'Step1'

    ?> 
    <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
    <td height="6" align="center" valign="middle">
    <h1 align="center">some info here</h1>
    <p>&nbsp;</p>
      <table cellSpacing="0" cellPadding="6" width="100%" border="0">
    <form action="?step=2" method="post" >
      <tr align="middle">
       <td width="33%"><input type="radio" value="1" name="plan"> test1</td>
         <td width="34%"><input type="radio" value="2" name="plan"> test2</td>
          <td width="33%"><input type="radio" value="3" name="plan"> test3</td>
          </tr>
         <tr align="middle">
        <td colSpan="3" width="742">
       <input class="butt" type="submit" value="next" name="next"></td>
      </tr>
     </form>
    </table>
    <?PHP 

    elseif(
    $step == '2'

    ?> 
    <form action="$_SERVER['PHP_SELF']" method="post" > 
                    <table width="450" border="0" align="center" cellpadding="2" cellspacing="1"> 
                      <tr> 
                      here some form for test 2
                      <tr> 
                        <td colspan="2"><div align="center"> 
                            <input class="butt" type="button" value="Next" style="width:150px" onClick="top.location.href='?step=3'; return'';"  > 
                          </div></td> 
                      </tr> 
                    </table> 
                  </form> 
    <form action="$_SERVER['PHP_SELF']" method="post" > 
                    <table width="450" border="0" align="center" cellpadding="2" cellspacing="1"> 
                      <tr> 
                     here some form for test 2
                      <tr> 
                        <td colspan="2"><div align="center"> 
                            <input class="butt" type="button" value="Next" style="width:150px" onClick="top.location.href='?step=3'; return'';"  > 
                          </div></td> 
                      </tr> 
                    </table> 
                  </form> 
    <form action="$_SERVER['PHP_SELF']" method="post" > 
                    <table width="450" border="0" align="center" cellpadding="2" cellspacing="1"> 
                      <tr> 
                      here some form for test 2
                      <tr> 
                        <td colspan="2"><div align="center"> 
                            <input class="butt" type="button" value="Next" style="width:150px" onClick="top.location.href='?step=3'; return'';"  > 
                          </div></td> 
                      </tr> 
                    </table> 
                  </form> 
    <? 


    ?> 

    <?PHP 
                                                                                 
    // 

    if(isset($HTTP_POST_VARS['step'])) 

        
    $smolf3d['step'] = $HTTP_POST_VARS['step']; 

    elseif(isset(
    $HTTP_GET_VARS['step'])) 

        
    $smolf3d['step'] = $HTTP_GET_VARS['step']; 

    else 

        
    $smolf3d['step'] = '1'


    if(
    $step =='1'

           


    if(
    $step =='2'

        

    ?>

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry but could you be a little more descriptive? Thanks!

    Joe

  3. #3
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i don't know how to speake with you,because my english very bad .

    hee example http://www.smolf3d.net/test/step.phtml

  4. #4
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Smolf3d
    i don't know how to speake with you,because my english very bad .

    hee example http://www.smolf3d.net/test/step.phtml
    No problem. I'm still not sure what you are trying to accomplish so maybe someone else could help.

    Joe

  5. #5
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Smolf3d,

    Are you saying that upon selection of one of the radio boxes in your example, of which you are test1, test2, and test3, you want to open different pages depending on which was selected?

    I.e., if the user selected test1, then take them to test1.html? If they selected test2, then take them to test2.html?

    If so, then you could do:
    PHP Code:
    if ($yourVariable == "test1")
    {
       
    $page "test1.html";
    }

    include (
    $page); 
    Does that help at all?

  6. #6
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by krayziepjf
    Smolf3d,

    Are you saying that upon selection of one of the radio boxes in your example, of which you are test1, test2, and test3, you want to open different pages depending on which was selected?

    I.e., if the user selected test1, then take them to test1.html? If they selected test2, then take them to test2.html?

    If so, then you could do:
    PHP Code:
    if ($yourVariable == "test1")
    {
       
    $page "test1.html";
    }

    include (
    $page); 

    Does that help at all?

    no .

    if the user selected test1, then take them to test1.phtml?step=2 If they selected test2, then take them to test1.phtml?step=2 If they selected test3, then take them to test1.phtml?step=2

    in test1.phtml?step=2 , 3 forms , if get test1 he open for some one this form.

  7. #7
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, let me try again. Is it that you are never getting to the test1.phtml?step=2 and seeing the 3 forms?

  8. #8
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by krayziepjf
    Ok, let me try again. Is it that you are never getting to the test1.phtml?step=2 and seeing the 3 forms?
    yes but

    if the user selected test1 , user can see only form for test1 and 2 other forms hide .

    if the user selected test2 , user can see only form for test2 and 2 other forms hide .

    if the user selected test3 , user can see only form for test3 and 2 other forms hide .

  9. #9
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the easiest way to do this is to use 4 different files.

    Your "index" file would display your three user options. The form on that page would action back to itself, as such (you could use get too, up to you):
    PHP Code:
    <form action='<?php echo($_SERVER["PHP_SELF"]); ?>' method='post'>
    Then, at the top of this file you would have:
    PHP Code:
       //display a page relevant to the option chosen.
    switch($page)
    {
        case 
    "test1":
           include(
    "test1.phtml");
           break;
        case 
    "test2":
           include(
    "test2.phtml");
           break;
        case 
    "test3":
           include(
    "test3.phtml");
           break;
       default:
          
    //the form was not submitted, so display the page with the 3 user options


  10. #10
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Idea not bad, could not you try to connect the youre code with my code? And that mine does not come out

  11. #11
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put the original code that you used to display the form in the screenshot you included in the default portion of the switch statement. Then, put whatever code you like in each of the other documents that you wish to display to the user depending on the option they chose.

  12. #12
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    224
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ok , thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •