Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    337
    Thanks
    44
    Thanked 2 Times in 2 Posts

    Need some help with form processing and showing errors.

    Hi!

    This is my very first somewhat complex form and I think I'm making this more difficult than it has to be. Just need somebody to set me on the right track so I have some direction.

    Now I've read that you shouldn't post to the same page and that you should post to a processing script and then re-display the original page. And I've also read that there is nothing wrong with posting to the same page and processes everything at the top. Which is what I'm trying to do. =|

    The page itself has or will have four sections:

    1) To select the team that is going to be updated and/or deleted, added or have a photo changed.
    2) Update/delete section
    3) Add to an existing team
    4) Change a photo.

    My initial feeling is that I should have a page for each form and a separate processing page.

    This is where I get lost. If the form submitted has errors how to you get the information back to the original page? This is the part where I get confused. If I had a clear example I can follow it but searching around yields people that have in one form or another asked the same thing. Noobish mistakes I call it. And I haven't really seen any clear answers.

    I appreciate the help and even more so if you could show me the way! =)

    Thanks

    Dave
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  • #2
    New Coder
    Join Date
    Aug 2014
    Posts
    97
    Thanks
    0
    Thanked 18 Times in 18 Posts
    In my opinion you should certainly process on the same page as the form and yes it can easily be done, actually it's easier to do than putting it on a different page and trying to show validation errors. I try no to link to my own site for reference but I have a tutorial on exactly what you are asking about. How to validate a form the right way - AME CMS

  • #3
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    337
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by fastsol View Post
    In my opinion you should certainly process on the same page as the form and yes it can easily be done, actually it's easier to do than putting it on a different page and trying to show validation errors. I try no to link to my own site for reference but I have a tutorial on exactly what you are asking about. How to validate a form the right way - AME CMS
    This gets a bit more tricky than that due to the fact that I'd actually have four forms on one page. At the moment I change the css display value to hide what should not be seen.

    Pardon some of the stuff in the code since I display variables to find out what is going on and where. My main problem is that on a refresh of the page that the displayed gets added to every time its refreshed which I believe is my doing but I can't track it down!

    PHP Code:
    <?php
    if( !isset( $_SESSION ) ) {
        
    session_start();
    }
    include_once(
    "config/config.db.php");
    include_once(
    "../scripts/functions.php");
    include_once(
    "functions/maint_functions.php");

    $pageTitle 'Franklin Township Soccer Club v3.0';
    $subTitle 'Team Mgmt Maintenance';
     
    $error1 0;
    $error2 0;
    $error_NoTeam "";
    $error_NoMaint "";
    $form1 "";

    $link mysqli_connect($DB_HOST,$DB_USER,$DB_PASS,$DB_NAME) or die("Error " mysqli_error($link)); 
    if (
    mysqli_connect_error()) {
        
    $logMessage 'MySQL Error: ' mysqli_connect_error();
        echo 
    $logMessage "<br>\n";
        die(
    'Could not connect to the database');


    /* VARIABLE STATUS DISPLAY */

    if (isset($_POST['submit_check1'])) {
        echo 
    "submit check1 is set<br>";
        } else {
                echo 
    "submit check1 is NOT set<br>";
    }

    echo 
    "form1 = $form1<br>";

    if (isset(
    $_POST['submit_check2'])) {
        echo 
    "submit check2 is set<br>";
        } else {
        echo 
    "submit check2 is NOT set<br>";
    }

    if (isset(
    $_POST['submit_check3'])) {
        echo 
    "submit check3 is set<br>";
        } else {
        echo 
    "submit check3 is NOT set<br>";
    }

    if (isset(
    $teams)) {
        echo 
    "array teams is set<br>";
        } else {
        echo 
    "array teams is NOT set<br>";
    }
    /* END VARIABLE STATUS DISPLAY */

    /* FIRST FORM TEAM DROPDOWN SELECT VALIDATION */
     
    if ((isset($_POST['submit_check1'])) and ($form1 == "")){
        
    $tVal explode("||",$_POST['team']);
        
    $_SESSION['teamNo'] = $tVal[0];
        
    $_SESSION['teamName'] = $tVal[1];
          
       if (
    $tVal[0] == "none") {
            
    $error_NoTeam "<br><span class='error-red'>Error: You must select a team!</span>";
            
    $error1++;
        }
        
        if (!isset(
    $_POST['ftype'])) {
            
    $error_NoMaint "<span class='error-red'>Error: You must select a maintenance type!</span>";
            
    $error1++;
        }
        
        if  (
    $error1 1) {
                echo 
    "errors greater than 0";            
                 
    $_SESSION['displayDiv1'] = "";
                 
    $_SESSION['displayDiv2'] = "style='display:none;'";
                 
    $_SESSION['displayDiv3'] = "style='display:none;'";
                 
    $_SESSION['displayDiv4'] = "style='display:none;'";
                }
        
        if (
    $error1 == 0) {
            if (isset(
    $_POST['ftype'])) {
                if (
    $_POST['ftype'] == "change") {
                        
    $_SESSION['displayDiv1'] = "style='display:none;'";
                        
    $_SESSION['displayDiv2'] = "";
                        
    $_SESSION['displayDiv3'] = "style='display:none;'";
                        
    $_SESSION['displayDiv4'] = "style='display:none;'";
                        
                        
    $mgmt_query "SELECT `teams`.`team_name`,`mgmt`.`mgmt-name`,`mgmt`.`email`,`mgmt`.`phone`,`coach-roles`.`mgmt_role`, `coach-roles`.`mgmt_position`, `mgmt`.`mgmt_id`,`teams`.`team_id` FROM teams LEFT JOIN `mgmt` ON `teams`.`team_id` = `mgmt`.`team_id` LEFT JOIN `coach-roles` ON `mgmt`.`mgmt_role` = `coach-roles`.`mgmt_role` WHERE(( team_name = \"" $_SESSION['teamName'] . "\"));";
                        
                        
    $mgmt_query_result mysqli_query($link$mgmt_query) or die(mysqli_error($link));
                        while (
    $mgmtrows mysqli_fetch_array($mgmt_query_resultMYSQLI_ASSOC)) {
                                
    $mgmt[] = $mgmtrows;
                        }        
                        
                        
    $_SESSION['mgmt'] = $mgmt;
                        
    $_SESSION['endcount'] = count($mgmt);
                        
                        
    $mgmtroles_query "SELECT `coach-roles`.`mgmt_role`, `coach-roles`.`mgmt_position` FROM `ftsc`.`coach-roles`;";
                        
    $mgmtroles_query_result mysqli_query($link$mgmtroles_query) or die(mysqli_error($link));
                        while (
    $mgmtrolerows mysqli_fetch_array($mgmtroles_query_resultMYSQLI_ASSOC)) {
                            
    $roles[] = $mgmtrolerows;
                        }                        
                        
                        if (!isset(
    $_SESSION['teams'])) {
                        
    $_SESSION['roles'] = $roles;
                        }
                        
                } 
    // ftype and change
                
                
    if ($_POST['ftype'] == "add") {
                        
    $_SESSION['displayDiv1'] = "style='display:none;'";
                        
    $_SESSION['displayDiv2'] = "style='display:none;'";
                        
    $_SESSION['displayDiv3'] = "";
                        
    $_SESSION['displayDiv4'] = "style='display:none;'";
                }    
    // ftype and add    
                
    $form1 "done";
            } 
    // end ftype is set
        

    } else {
            if (
    $form1 == "") {
                
    $team_query "SELECT `teams`.`team_id`,`teams`.`age_range`,`teams`.`sex`,`teams`.`team_name`,`teams`.`doc_path` FROM `ftsc`.`teams` ORDER BY `age_range`, `sex`;";
                
    $team_query_results mysqli_query($link$team_query) or die(mysqli_error($link));

                while (
    $teamrows mysqli_fetch_array ($team_query_resultsMYSQLI_ASSOC)) {
                    
    $teams[] = $teamrows;
                }
            }
    }

        
    // end if submitcheck1

    if (isset($_POST['submit_check2'])){

        
    $mquery "";

        for (
    $count 0$count $_SESSION['endcount']; $count++) {
        
            if (isset(
    $_POST['mgmtupdate-' $count])) {
                
    $updateFlag $_POST['mgmtupdate-' $count];
            }
            if (isset(
    $_POST['mgmtdelete-' $count])) {
                
    $updateFlag $_POST['mgmtdelete-' $count];
            }        
            if (isset( 
    $_POST['team-id-' $count])) {
                
    $teamId $_POST['team-id-' $count];
            }
            if (isset(
    $_POST['mgmt-id-' $count])) {
                
    $mgmtId $_POST['mgmt-id-' $count];
            }
            if (isset(
    $_POST['mgmt-name-' $count])) {
                
    $mgmtName $_POST['mgmt-name-' $count];
            }
            if (isset(
    $_POST['mgmt-role-' $count])) {
                
    $mgmtRole $_POST['mgmt-role-' $count];
            }
            if (isset(
    $_POST['email-' $count])) {
                
    $mgmtEmail $_POST['email-' $count];
            }
            if (isset(
    $_POST['phone-' $count])) {
                
    $mgmtPhone $_POST['phone-' $count];    
            }
            
            if (isset(
    $_POST['mgmtdelete-'$count]) && (isset($_POST['mgmtupdate-'$count]))) {
                
                if ((
    $_POST['mgmtdelete-'$count] == 'on') && ($_POST['mgmtupdate-'$count] == 'on')) {
                    echo 
    "You cannot select both update and delete!  Please correct and resubmit!";
                    
    $error2++;
                }

                if ((
    $_POST['mgmtdelete-'$count] == 'off') && ($_POST['mgmtupdate-'$count] == 'off')) {
                    echo 
    "You must select either Update or Delete!  Please correct and resubmit!";
                    
    $error2++;
                }                
            
            }
                
            if (isset(
    $_POST['email-' $count])) {
                if (
    check_email_address($mgmtEmail)) {
                    echo 
    '<img src="../images/green-check.png" height="18px" width="18px" border=0 />' .$mgmtEmail ' is a valid email address.' "<br><br>\n";
                } else {
                    
    $error2++;
                    echo 
    '<img src="../images/red-x.png" height="18px" width="18px" border=0 />' $mgmtEmail ' is not a valid email address.' "<br><br>\n";
                }
            }
            
            if (isset(
    $_POST['phone-' $count])) {
                if ( 
    validate_phone($mgmtPhone)) {
                    echo 
    '<img src="../images/green-check.png" height="18px" width="18px" border=0 />' .$mgmtPhone ' is a valid phone number.' "<br><br>\n";
                    
    $mgmtPhone unfmtPhone($mgmtPhone);
                } else {
                    
    $error2++;
                    echo 
    '<img src="../images/red-x.png" height="18px" width="18px" border=0 />' $mgmtPhone ' is not a valid phone number.' "<br><br>\n";
                }
            }
        } 
    // end for 
    // end submit if

    /* <<<< END >>>> FIRST FORM TEAM DROPDOWN SELECT VALIDATION */


    ?>

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Franklin Township Soccer Club" />
    <meta name="author" content="Dave Handler" />
    <link rel="shortcut icon" href="images/favicon.ico" />

    <title><?php echo $pageTitle?></title>

    <!-- Google Web Fonts -->    
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css' />    
    <!-- Custom Icons Fonts --> 
    <link href='../fonts/stylesheet.css' rel='stylesheet' type='text/css' />
    <!-- Maintence form style -->
    <link href='css/maint-style.css' rel='stylesheet' type='text/css' />

    <!--  JQuery load  -->
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'  type="text/javascript" charset="utf-8"></script>

    </head>

    <body>

    <div id="page_container">

        <div id="header">
            <div id="header-graphic">
                <div id="header-mute">
                    <h1 class="three-d" style="padding:65px 0 0 25px">Franklin Township Soccer Club</h1>
                    <h2 class="three-d" style="padding:13px 0 0 25px;margin-top:-20px;font-size:30px"><?php echo $subTitle?></h2>
                </div>
              </div>
            <div id="smoothcontainer"></div>
                 
        </div>

    <div style="clear:both;"></div>

    <?php "/r/n"?>

        <div id='content'>

    <!-- ***************************** DROP DOWN TO SELECT TEAM *************************************** -->

            <div class='team-select-container' <?php echo $_SESSION['displayDiv1']; ?>>
                <form action="<?php $_SERVER['PHP_SELF'?>" method="post">
                    <div style='width:325px;height:100px;float:left;'>
                        <h3 class='team-select-title'>Select Team</h3>
                        <div class='team-selector'>
                            <select name='team' class='form-field'>
                                <option value="none||none">Select Team</option>
    <?php foreach ($teams as $teams_value) { ?>
                                <option value="<?php  echo $teams_value['team_id'] . "||" .$teams_value['team_name']; ?>"><?php echo $teams_value['age_range'] . " " $teams_value['sex'] . " " $teams_value['team_name']; ?></option>
    <?php ?> 
                            </select>
                            <?php echo $error_NoTeam?>
                        </div>
                    </div>
                    <div style='width:325px;height:100px;float:left;'>
                        <h3 class='team-select-title'>Select Maintenance Type</h3>
                        <div class="radStyle">
                            <input type='radio' name='ftype' value='change' id='chg' class='css-radiobox'><label for='chg' class='css-label radGroup1'>Update/Delete Mgmt</label>
                        </div>
                        <div class="radStyle">
                            <input type='radio' name='ftype' value='add' id='add' class='css-radiobox'><label for='add' class='css-label radGroup1'>Add Mgmt</label>
                        </div>
                        <div class="radStyle">
                            <input type='radio' name='ftype' value='photo' id='photo' class='css-radiobox'><label for='photo' class='css-label radGroup1'>Photo Change</label>
                        </div>                    
                        <?php echo $error_NoMaint?>
                    </div>

                    <div style='width:325px;height:100px;float:left;'>
                        <input type='submit' name='maint' value='Submit' id='maint' class='submit-button-maint' />
                        <input type='hidden' name='submit_check1' value='1' />
                    </div>
                </form>
            <div style="clear:both;"></div>
            </div>

    <?php
    /* VARIABLE STATUS DISPLAY */

    if (isset($_POST['submit_check1'])) {
        echo 
    "submit check1 is set<br>";
        } else {
                echo 
    "submit check1 is NOT set<br>";
    }

    echo 
    "form1 = $form1<br>";

    if (isset(
    $_POST['submit_check2'])) {
        echo 
    "submit check2 is set<br>";
        } else {
        echo 
    "submit check2 is NOT set<br>";
    }

    if (isset(
    $_POST['submit_check3'])) {
        echo 
    "submit check3 is set<br>";
        } else {
        echo 
    "submit check3 is NOT set<br>";
    }

    if (isset(
    $teams)) {
        echo 
    "array teams is set<br>";
        } else {
        echo 
    "array teams is NOT set<br>";
    }
    /* END VARIABLE STATUS DISPLAY */
    ?>

            
            <div class='team-select-container' <?php echo $_SESSION['displayDiv2']; ?>>
    <!-- ==================================================================================================================================== -->
                <form action="<?php $_SERVER['PHP_SELF'?>" method="post">
                    <table class="mgmtchg">
                        <tr>
                            <th>Management Role</th>
                            <th>Name</th>
                            <th>Email address</th>
                            <th>Phone</th>
                            <th>&nbsp;&nbsp;&nbsp;&nbsp;Update</th>
                            <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delete</th>
                        </tr>
    <?php
    $count 
    0;
    foreach ( 
    $_SESSION['mgmt'] as $mgmt_value ) { ?>
                        <tr>
                            <td class="mgmttd">
                                <select name="mgmt-role-<?php echo $count?>" class="mgmt-<?php echo $count?> form-field role-drop" disabled >
        <?php foreach ( $_SESSION['roles'] as $role_value ) {
            if ( 
    $role_value['mgmt_role'] == $mgmt_value['mgmt_role'] ) { ?>
                                    <option value="<?php echo $role_value['mgmt_role']; ?>" selected><?php echo $role_value['mgmt_position']; ?></option>    
            <?php }
            else { 
    ?>
                                    <option value="<?php echo $role_value['mgmt_role']; ?>"><?php echo $role_value['mgmt_position']; ?></option>
            <?php }
        } 
    ?>
                                </select>
                            </td>
                            <td class="mgmttd">
                                <input type="hidden" name="mgmt-id-<?php echo $count?>" value="<?php echo $mgmt_value['mgmt_id']; ?>" /><input type="hidden" name="team-id-<?php echo $count?>" value="<?php echo $mgmt_value['team_id']; ?>" /><input type="text" name="mgmt-name-<?php echo $count?>" class="mgmt-<?php echo $count?> form-field mgmt-name-field" disabled value="<?php echo $mgmt_value['mgmt-name']; ?>" />
                            </td>
                            <td class="mgmttd">
                                <input type="text" name="email-<?php echo $count?>" class="mgmt-<?php echo $count?> form-field mgmt-email-field" disabled value="<?php echo $mgmt_value['email']; ?>" />
                            </td>
                            <td class="mgmttd">
                                <input type="text" name="phone-<?php echo $count?>" class="mgmt-<?php echo $count?> form-field mgmt-phone-field" disabled value="<?php echo $mgmt_value['phone']; ?>" />
                            </td>
                            <td class="mgmttd">
                                <div class="chgradio"><input type="radio" name="utype<?php echo $count?>" value="upd-<?php echo $count?>" id="mgmtupdate-<?php echo $count?>" class="css-radiobox"><label for="mgmtupdate-<?php echo $count?>" class="css-label radGroup2"></label></div>
                            </td>
                            <td class="mgmttd">
                                <div class="chgradio"><input type="radio" name="utype<?php echo $count?>" value="del-<?php echo $count?>" id="mgmtdelete-<?php echo $count?>" class="css-radiobox"><label for="mgmtdelete-<?php echo $count?>" class="css-label radGroup2"></label></div>
                            </td>
                        </tr>
    <?php    $count++;
    }
    ?>
                    </table>
                    <input type="submit" name="submit" value="submit" id="formsubmit" class="submit-button-chg" />
                    <input type="hidden" name="team-id" value="<?php echo $mgmt_value["team_id"]; ?>" />
                    <input type="hidden" name="submit_check2" value="1" />
                </form>

    <script type="text/javascript">
    jQuery(document).ready(function($) {
                
    <?php 
        
    for ($count 0$count $endcount$count++) {
    ?>            
                
    $(".css-radiobox").click(function () {
        $(".mgmt-<?php echo $count?>").attr("disabled", true);
        if ($("input[name=utype<?php echo $count?>]:checked").val() == "upd-<?php echo $count?>") {
            $(".mgmt-<?php echo $count?>").attr("disabled", false);
        }
    });            
                
    <?php
        
    }
    ?>
        
    });

    </script>            
                
    <!-- ==================================================================================================================================== -->
            </div>
            
            
            
            <div class='team-select-container' <?php echo $_SESSION['displayDiv3']; ?>></div>        


        </div>

        <div id='footer'>

            <div id="btm_stuff">
            
                <div class="btm-logo-wrapper left btm-logo">
                    <img src="../images/site/ftsc-swoosh.png" width="224px" height="166px" alt="FTSC logo" />
                </div>
                
                <div class="btm-info-wrapper">
                        <div id="contact-info">
                            If you have questions use our <a href="needhelp.php">contact</a> form or our telephone hotline 317-767-1077
                        </div>
                    
                        <div class='best-view'>
                            This website best viewed in Firefox 8+, Chrome 10+, Opera 10+ and Internet Explorer 8+
                        </div>
                    
                        <div class='best-view'>
                            <p id="browser-info-here">The browser you are using is <font style="color:red"><?php $ua=getBrowser();$yourbrowser=  $ua['name'] . " " $ua['version'];print_r($yourbrowser);?></font></p>
                        </div>
                        
                        <div id='copy-right'>
                            &copy; 1994 - 2014 Franklin Township Soccer Club (ftscoccer.org &amp; ftsoccer.com)
                        </div>
                    
                        <div id='webmstr'>
                            <a href="webmaster.php">Question/Comments</a> about this website can be directed to the webmaster.
                        </div>
                        
                        <div class="footer-icon">
                            <p class="icon-text"><a href="https://plus.google.com/112894921187789216773" rel="publisher">G</a></p><p class="icon-text"><a href="http://www.facebook.com/pages/Franklin-Township-Soccer-Club/123828377634738">F</a></p>
                        </div>
                        
                        <div id="lastupdate">
                            <?php
                                $last_mod 
    date("l F j, Y g:i a"filemtime(substr(strrchr($_SERVER['PHP_SELF'], '/'),1)));
                                echo 
    "<div id='last-modfy'>Page Last Modified - $last_mod</div>";
                            
    ?>                    
                        </div>
                
                </div>
            
            </div>
        
        </div>        
        
        
    </div>

    <script type="text/javascript">

    document.getElementById('mgmtupdate-0').onchange = displayTextBox;
    document.getElementById('mgmtdelete-0').onchange = displayTextBox;

    var textBox = document.getElementsByClassName('mgmt-0');

    function displayTextBox(evt){
        console.log(evt.target.value)
        if(evt.target.value=="upd-0"){
            textBox.disabled = false;
        }else{
            textBox.disabled = true;
        }
    }

    </script>
     
    </body>

    </html>
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,211
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    And there's no reason to have a page for each <form>. You could, for example, put each <form> on its own "tab" (though you don't have to).

    If you simply use a hidden field to identify WHICH form is being processed, then the PHP code can easily do the right thing.

    Code:
    <form id="deleteForm" method="post">
    <input type="hidden" name="whichForm" value="deleteForm"/>
    ...
    </form>
    And then PHP code such as:
    Code:
    $which = $_POST["whichForm"];
    if ( isset($which) ) 
    {
        switch ( $which )
        {
            case "deleteForm":...
            break;
            ...
        }
    }
    No? Seems simple enough.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    MrBiggZ (09-08-2014)

  • #5
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    337
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Old Pedant View Post
    And there's no reason to have a page for each <form>. You could, for example, put each <form> on its own "tab" (though you don't have to).

    If you simply use a hidden field to identify WHICH form is being processed, then the PHP code can easily do the right thing.

    Code:
    <form id="deleteForm" method="post">
    <input type="hidden" name="whichForm" value="deleteForm"/>
    ...
    </form>
    And then PHP code such as:
    Code:
    $which = $_POST["whichForm"];
    if ( isset($which) ) 
    {
        switch ( $which )
        {
            case "deleteForm":...
            break;
            ...
        }
    }
    No? Seems simple enough.
    I think I see where you're going with that. You can also set a variable to determine which form to display too! (guessing)

    Do I still need to do use $_SESSION with this method?
    Last edited by MrBiggZ; 09-08-2014 at 12:28 AM.
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,211
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    Quote Originally Posted by MrBiggZ View Post
    I think I see where you're going with that. You can also set a variable to determine which form to display too! (guessing)
    Ummm...it's the same variable. If $which is "deleteForm" than that's the one you display, for example. If $which is *NOT* set, then it's the first time on the page, so in the else of that first if that I showed, you just assign the id/name of the default form you want displayed first. Presto.

    Do I still need to do use $_SESSION with this method?
    How can we know? It depends on what info you need to carry over from one <form> submittal to the next.

    Yes, I would think you would always need $_SESSION["userid"], for example.

    But only you can decide what other values you might need for all subsequent <form> submittals.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    337
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Old Pedant View Post
    Ummm...it's the same variable. If $which is "deleteForm" than that's the one you display, for example. If $which is *NOT* set, then it's the first time on the page, so in the else of that first if that I showed, you just assign the id/name of the default form you want displayed first. Presto.


    How can we know? It depends on what info you need to carry over from one <form> submittal to the next.

    Yes, I would think you would always need $_SESSION["userid"], for example.

    But only you can decide what other values you might need for all subsequent <form> submittals.
    Thanks Old!

    I'm working my way through this! The kick start was what I needed. I didn't even think of using the switch at first which made it so much easier to manage and look at!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs


  •  

    Tags for this Thread

    Posting Permissions

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