Jump to content

twilitegxa

Members
  • Posts

    1,020
  • Joined

  • Last visited

Posts posted by twilitegxa

  1. Rest of the code:

     

    <td class=align_levels>$attribute_level</td>
    <td class=align_levels>$attributes_points</td>
    </tr>";
    
    }
    }
    
    $get_sub_attributes = "select * from scout_sub_attributes where identity = '$identity'";
    $get_sub_attributes_res = mysql_query($get_sub_attributes, $conn) or die(mysql_error());
    
    while ($sub_attributes_info = mysql_fetch_array($get_sub_attributes_res)) {
        $sub_attributes_id = $sub_attributes_info['id'];
        $sub_attributes_identity = $sub_attributes_info['identity'];
        $sub_attributes_attribute_id = $sub_attributes_info['sub_attribute_id'];
        $sub_attributes_level_id = $sub_attributes_info['level_id'];
        $sub_attributes_notes = $sub_attributes_info['notes'];
        
    $get_sub_attribute_names = "select * from sub_attributes where id = '$sub_attributes_attribute_id'";
    $get_sub_attribute_names_res = mysql_query($get_sub_attribute_names, $conn) or die(mysql_error());
    
    while ($sub_attribute_names_info = mysql_fetch_array($get_sub_attribute_names_res)) {
        $sub_attribute_names_id = $sub_attribute_names_info['id'];
        $sub_attribute_names_attribute = $sub_attribute_names_info['sub_attribute'];
        $sub_attribute_names_points = $sub_attribute_names_info['points'];
        $sub_attributes_points = ($sub_attribute_names_points * $sub_attributes_level_id);
    
    $display_block .= "
    <tr>
    <td class=indent>$sub_attribute_names_attribute</td>";    
    
    if ($sub_attributes_level_id == null) {
        $display_block .= "<td> </td>
        <td> </td></tr>";
        } else {
    $display_block .= "
    <td class=align_levels>$sub_attributes_level_id</td>
    <td class=align_levels>$sub_attributes_points</td></tr>";
    }
    
    //gather attacks
    $get_items = "select * from items where identity = '$identity' and acquired = 1 order by level asc";
    $get_items_res = mysql_query($get_items, $conn) or die(mysql_error());
    
    while ($items_info = mysql_fetch_array($get_items_res)) {
        $item_id = $items_info['id'];
        $item_identity = $items_info['identity'];
        $items = $items_info['item'];
        $item_desc = $items_info['desc'];
        $item_level = $items_info['level'];
        $item_points = ($sub_attribute_names_points * $item_level);
        
    if ($sub_attribute_names_attribute == 'Item Of Power') {
    $display_block .= "
    <tr>
    <td class=indent2>- $items</td>
    <td class=align_levels>$item_level</td>
    <td class=align_levels>$item_points</td>
    </tr>
    <tr>";
    
    }
    }
    
    }
    }
    
    //gather attacks
    $get_attacks = "select * from attacks where identity = '$identity' and level <= '$character_attack_level' and learned = 1 order by level desc";
    $get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error());
    
    while ($attacks_info = mysql_fetch_array($get_attacks_res)) {
        $attack_id = $attacks_info['id'];
        $attack_identity = $attacks_info['identity'];
        $attack = $attacks_info['attack'];
        $primary = $attacks_info['primary_attack'];
        $secondary = $attacks_info['secondary_attack'];
        $attack_level = $attacks_info['level'];
        $attack_points = ($sub_attribute_names_points * $attack_level);
        $learned = $attacks_info['learned'];
        
    //checks for primary and secondary attacks
        if($secondary == 1) $attack_points = 2;
    elseif($primary == 0 && $secondary == 0) $attack_points = 1;
    
    if ($sub_attribute_names_attribute == 'Sailor Scout Attack') {
    $display_block .= "
    <tr>
    <td class=indent2>- $attack</td>
    <td class=align_levels>$attack_level</td>
    <td class=align_levels>$attack_points</td>
    </tr>
    <tr>";
    
    }
    }
    
    //gather neutral attributes
    $get_neutral_attributes = "select * from scout_neutral_attributes where identity = '$identity'";
    $get_neutral_attributes_res = mysql_query($get_neutral_attributes, $conn) or die(mysql_error());
    
    while ($neutral_attributes_info = mysql_fetch_array($get_neutral_attributes_res)) {
        $neutral_attributes_id = $neutral_attributes_info['id'];
        $neutral_attributes_identity = $neutral_attributes_info['identity'];
        $neutral_attributes_attribute_id = $neutral_attributes_info['attribute_id'];
        $neutral_attributes_level_id = $neutral_attributes_info['level_id'];
        
    $get_neutral_attribute_names = "select * from neutral_attributes where id = '$neutral_attributes_attribute_id'";
    $get_neutral_attribute_names_res = mysql_query($get_neutral_attribute_names, $conn) or die(mysql_error());
    
    while ($neutral_attribute_names_info = mysql_fetch_array($get_neutral_attribute_names_res)) {
        $neutral_attribute_names_id = $neutral_attribute_names_info['id'];
        $neutral_attribute_names_attribute = $neutral_attribute_names_info['attribute'];
        $neutral_attribute_names_points = $neutral_attribute_names_info['points'];
        $neutral_attribute_points = ($neutral_attributes_level_id * $neutral_attribute_names_points);
        
    $display_block .= "
    <tr>
    <td>$neutral_attribute_names_attribute</td>
    <td class=align_levels>$neutral_attributes_level_id</td>
    <td class=align_levels>$neutral_attribute_points</td>
    </tr>";
    
    }
    }
    
    $display_block .= "
    </table></td></tr></table><br>";
    
    $display_block .= "
    <table border=0 width=100%>
    <tr>
    <td width=50% valign=top>
    <table>
    <tr>
    <td align=center><h1>Items Of Power</h1></td>";
    
    $get_items = "select * from items where identity = '$identity' and acquired = 1";
    $get_items_res = mysql_query($get_items, $conn) or die(mysql_error());
    
    while ($items_info = mysql_fetch_array($get_items_res)) {
        $items_id = $items_info['id'];
        $items_identity = $items_info['identity'];
        $item = $items_info['item'];
        $item_desc = nl2br($items_info['desc']);
        $item_level = $items_info['level'];
        $item_points = ($sub_attribute_names_points * $item_level);
        
    $display_block .= "
    <tr>
    <td class=hanging-indent>
    <i>$item --- </i><br>
    $item_desc</td></tr>";
    
    }
    
    $display_block .= "</table></td><td valign=top width=50%>
    <table>
    <tr>
    <td align=center><h1>Sailor Scout Attacks</td></tr>";
    
    //gather attacks
    $get_attacks = "select * from attacks where identity = '$identity' and learned = 1 order by level asc";
    $get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error());
    
    while ($attacks_info = mysql_fetch_array($get_attacks_res)) {
        $attack_id = $attacks_info['id'];
        $attack_identity = $attacks_info['identity'];
        $attack = $attacks_info['attack'];
        $attack_desc = nl2br($attacks_info['desc']);
        $primary = $attacks_info['primary_attack'];
        $secondary = $attacks_info['secondary_attack'];
        $attack_level = $attacks_info['level'];
        $attack_points = ($sub_attribute_names_points * $attack_level);
        
        $display_block .= "
    <tr>
    <td class=hanging-indent>
    <i>$attack --- </i><br>
    $attack_desc</td></tr>";
    
    }
    
    $display_block .= "</table></td></tr></table>";
    
    $display_block .= "<table border=0 cellpadding=3 cellspacing=3 width=100%>
        <tr>
        <td width=50% valign=top>
        <table>
        <tr>
        <td align=center><h1>Transformations</h1></td>
        </tr>";
    
    $get_transformations = "select * from transformations where identity = '$identity'";
    $get_transformations_res = mysql_query($get_transformations, $conn) or die(mysql_error());
    
    while ($transformation_info = mysql_fetch_array($get_transformations_res)) {
        $transformation_id = $transformation_info['id'];
        $transformation_identity = $transformation_info['identity'];
        $transformation = $transformation_info['transformation'];
        $transformation_desc = $transformation_info['desc'];
        $transformation_level = $transformation_info['level'];
        
        $display_block .= "
        <tr>
        <td class=hanging-indent>
        <i>$transformation --- </i><br>
        $transformation_desc</td></tr>";
        
        }
        
        $display_block .= "</table></td>
        <td width=50% valign=top>
        <table>
        <tr>
        <td align=center><h1>Attribute/Sub-Attribute Notes</h1></td></tr>
        <tr>
        <td>
        <ol>";
        
    //gather attributes and sub-attributes notes
    
    $get_sub_notes = "select * from scout_sub_attributes where identity = '$identity' and notes IS NOT NULL";
    $get_sub_notes_res = mysql_query($get_sub_notes, $conn) or die(mysql_error());
    
    while ($sub_notes_info = mysql_fetch_array($get_sub_notes_res)) {
        $sub_notes = nl2br($sub_notes_info['notes']);
        $sub_id = $sub_notes_info['sub_attribute_id'];
        
        $display_block.= "
        <li>$sub_notes</li>";
        
        }
        
    //gather neutral notes
    
    $get_neutral_notes = "select notes from scout_neutral_attributes where identity = '$identity' and notes IS NOT NULL";
    $get_neutral_notes_res = mysql_query($get_neutral_notes, $conn) or die(mysql_error());
    
    while ($neutral_notes_info = mysql_fetch_array($get_neutral_notes_res)) {
        $neutral_notes = nl2br($neutral_notes_info['notes']);
        
        $display_block .= "
        <li>$neutral_notes</li>";
        
        }
        
    //gather defect notes
    
    $get_defect_notes = "select notes from scout_defects where identity = '$identity' and notes IS NOT NULL";
    $get_defect_notes_res = mysql_query($get_defect_notes, $conn) or die(mysql_error());
    
    while ($defect_notes_info = mysql_fetch_array($get_defect_notes_res)) {
        $defect_notes = nl2br($defect_notes_info['notes']);
        
        $display_block .= "
        <li>$defect_notes</li>";
        
        }
        
        $display_block .= "</ol></table></td></tr></table>";
    
    ?>
    <html>
    <head>
    <title><?php print $identity; ?>'s Profile</title>
    <style type="text/css" media="screen">
    /*<![CDATA[*/
    @import url(global.css); 
    /*]]>*/
    </style>
    </head>
    <body>
    <!-- HEADER -->
    <h1 class="logo">Sailor Moon RPG</h1>
    <!-- /HEADER -->
    <?php include("topnav.php"); ?>
    <div id="main">
    <?php include("includes/log.php"); ?>
    <?php include("mainnav.php"); ?>
    <h1 align="center"><?php print $identity; ?></h1>
    <?php print $display_block; ?>
    <table width="100%">
    <tr>
    <td align="center">
    <h3>Would you like to use this character?</h3>
    <a href="accept_character.php"><input type="button" value="Yes" /></a>
    <a href="existing.php"><input type="button" value="No" /></a>
    </td>
    </tr>
    </table>
    </div>
    <?php include("bottomnav.php"); ?><!-- FOOTER -->
    <!-- FOOTER -->
    <div id="footer_wrapper">
    <div id="footer">
    <p>Sailor Moon and all characters
    are<br /> 
    trademarks of Naoko Takeuchi.</p>
    <p>Copyright © 2009 Liz Kula. All rights reserved.<br />
    A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
    <div id="foot-nav">
    <ul>
    <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
    <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
    </ul>
    </div>
    </div>
    </div>
    <!-- /FOOTER -->
    </body>
    </html>
    

  2. Here is the code for the page that has the button:

     

    <?php
    
    session_start();
    
    //Access Tracking Snippet
    
    //set up static variables
    $page_title = "showprofile.php";
    $user_agent = getenv("HTTP_USER_AGENT");
    $date_accessed = date("Y-m-d");
    
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
        or die(mysql_error());
    $db = mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    //create and issue query
    $sql = "insert into access_tracker values
        ('', '$page_title', '$user_agent', '$date_accessed')";
    mysql_query($sql,$conn);
    ?>
    
    <?php
    //check for required info from the query string
    if (!$_GET['id']) {
        header("Location: listcharacters.php");
        exit;
    }
    
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
        or die(mysql_error());
    mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    //verify the topic exists
    $verify_topic = "select identity from scouts where
        id = $_GET[id]";
    $verify_topic_res = mysql_query($verify_topic, $conn)
        or die(mysql_error());
    
    if (mysql_num_rows($verify_topic_res) < 1) {
        //this character does not exist
        $display_block = "<p><em>You have selected an invalid character.
        Please <a href=\"listcharacters.php\">try again</a></em></p>";
    } else {
        //gather rest of profile
        $get_posts = "select *, date_format(create_time, '%b %e %Y at %r') as fmt_scout_create_time from scouts where id = $_GET[id]";
            
        $get_posts_res = mysql_query($get_posts, $conn) or die(mysql_error());
        
        //create the display string
        $display_block = "
        <table cellpadding=3 cellspacing=1 border=0 class=list_tables>";
        
        while ($posts_info = mysql_fetch_array($get_posts_res)) {
            $post_id = $posts_info['id'];
            $identity = ucwords($posts_info['identity']);
            $character_create_time = $posts_info['fmt_scout_create_time'];
            $username = $posts_info['username'];
            $name = ucwords(strtolower($posts_info['name']));
            $element_of_influence = $posts_info['element_of_influence'];
            $age = $posts_info['age'];
            $birth_month = $posts_info['birth_month'];
            $birth_date = $posts_info['birth_date'];
            $birth_year = $posts_info['birth_year'];
            $height_feet = $posts_info['height_feet'];
            $height_inches = $posts_info['height_inches'];
            $blood_type = strtoupper($posts_info['blood_type']);
            $hobbies = ucwords(strtolower($posts_info['hobbies']));
            $favorite_color = ucwords(strtolower($posts_info['favorite_color']));
            $favorite_gemstone = ucwords(strtolower($posts_info['favorite_gemstone']));
            $favorite_food = ucwords(strtolower($posts_info['favorite_food']));
            $least_favorite_food = ucwords(strtolower($posts_info['least_favorite_food']));
            $favorite_school_subject = ucwords(strtolower($posts_info['favorite_school_subject']));
            $least_favorite_school_subject = ucwords(strtolower($posts_info['least_favorite_school_subject']));
            $strengths = ucwords(strtolower($posts_info['strengths']));
            $weaknesses = ucwords(strtolower($posts_info['weaknesses']));
            $goal = ucfirst($posts_info['goal']);
            $mission = ucfirst($posts_info['mission']);
            $biography = nl2br($posts_info['biography']);
            $biography = str_replace("\n", "<p>", $biography );
            $getMonth = date('F', mktime(0, 0, 0, $birth_month));
            $character_attack_level = $posts_info['attack_level'];
            
        $get_images = "select * from upload where identity = '$identity'";
        $get_images_res = mysql_query($get_images, $conn) or die(mysql_error());
        
        while ($images_info = mysql_fetch_array($get_images_res)) {
            $image_id = $images_info['id'];
            $image_identity = $images_info['identity'];
            $image_name = $images_info['name'];
            $image_type = $images_info['type'];
            $image_size = $images_info['size'];
            $image_content = $images_info['content'];
            
            //add to display
            $display_block .= "
            <tr>
            <td width=24% valign=top><strong>Character Name:</strong></td>
            <td width=55% valign=top>$name</td>
            <td align=center valign=top rowspan=18><img src='download.php?id=$image_id'></td>
            </tr>
            <tr>
            <td><strong>Element Of Influence:</strong></td>
            <td>$element_of_influence</td>
            </tr>
            <tr>
            <td><strong>Age:</strong></td>
            <td>$age</td>
            </tr>
            <tr>
            <td><strong>Date Of Birth:</strong></td>
            <td>$getMonth $birth_date, $birth_year</td>
            </tr>
            <tr>
            <td><strong>Height:</strong></td>
            <td>$height_feet feet $height_inches inches</td>
            </tr>
            <tr>
            <td><strong>Blood Type:</strong></td>
            <td>$blood_type</td>
            </tr>
            <tr>
            <td><strong>Hobbies:</strong></td>
            <td>$hobbies</td>
            </tr><tr>
            <td><strong>Favorite Color:</strong></td>
            <td>$favorite_color</td>
            </tr>
            <tr>
            <td><strong>Favorite Gemstone:</strong></td>
            <td>$favorite_gemstone</td>
            </tr>
            <tr>
            <td><strong>Favorite Food:</strong></td>
            <td>$favorite_food</td>
            </tr>
            <tr>
            <td><strong>Least Favorite Food:</strong></td>
            <td>$least_favorite_food</td>
            </tr>
            <tr>
            <td><strong>Favorite School Subject:</strong></td>
            <td>$favorite_school_subject</td>
            </tr>
            <tr>
            <td><strong>Least Favorite School Subject:</strong></td>
            <td>$least_favorite_school_subject</td>
            </tr>
            <tr>
            <td><strong>Strengths:</strong></td>
            <td>$strengths</td>
            </tr>
            <tr>
            <td><strong>Weaknesses:</strong></td>
            <td>$weaknesses</td>
            </tr>
            <tr>
            <td><strong>Goal:</strong></td>
            <td>$goal...</td>
            </tr>
            <tr>
            <td><strong>Mission:</strong></td>
            <td>$mission.</td>
            </tr>
            <td> </td>
            <td> </td>
            </tr>
            <tr>
            <td align=right colspan=3>Created By: <strong>$username</strong><br>
            Created On: <em>$character_create_time</em></td>
            </tr>";
            }
            
            //close up the table
            $display_block .= "</table><br>
            <p>$biography</p><br>";
    }
    }
    
    //gather stats and derived values; fix where statement
    
    $get_stats = "select * from stats where identity = '$identity'";
    
    $get_stats_res = mysql_query($get_stats, $conn) or die(mysql_error());
    
    $display_block .= "
    <table cellpadding=3 cellspacing=3 border=0 width=100%>";
    
    while ($stats_info = mysql_fetch_array($get_stats_res)) {
            $body = $stats_info['body'];
            $mind = $stats_info['mind'];
            $soul = $stats_info['soul'];
            
    $display_block .= "
    <tr>
    <td valign=top>
    <table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables>
    <th colspan=3>Stats And Derived Values</th>
    <tr>
    <td>Body</td>
    <td class=align_levels>$body</td>
    <td> </td>
    </tr>
    <tr>
    <td>Mind</td>
    <td class=align_levels>$mind</td>
    <td> </td>
    </tr>
    <tr>
    <td>Soul</td>
    <td class=align_levels>$soul</td>
    <td> </td>
    </tr>";
    }
    
    //gather derived values
    $get_derived = "select * from derived_values where identity = '$identity'";
    
    $get_derived_res = mysql_query($get_derived, $conn) or die(mysql_error());
    
    while ($derived_info = mysql_fetch_array($get_derived_res)) {
        $health = $derived_info['health'];
        $energy = $derived_info['energy'];
        $acv1 = $derived_info['acv1'];
        $acv2 = $derived_info['acv2'] . ' (for Sailor Scout Attack)';
        $dcv1 = $derived_info['dcv1'];
        $dcv2 = $derived_info['dcv2'] . ' (for Sailor Scout Attack)';
        $total_cp = $derived_info['total_cp'];
        
    if($health == 0 || $health == '0' || $health == null){$GLOBALS['health'] = "";}
    if($energy == 0 || $energy== '0' || $energy == null){$GLOBALS['energy'] = "";}
    if($acv1 == 0 || $acv1 == '0' || $acv1 == null){$GLOBALS['acv1'] = "";}
    if($acv2 == 0 || $acv2 == '0' || $acv2 == null){$GLOBALS['acv2'] = "";}
    if($dcv1 == 0 || $dcv1 == '0' || $dcv1 == null){$GLOBALS['dcv1'] = "";}
    if($dcv2 == 0 || $dcv2 == '0' || $dcv2 == null){$GLOBALS['dcv2'] = "";}
    if($total_cp == 0 || $total_cp == '0' || $total_cp== null){$GLOBALS['total_cp'] = "";}
    
    $display_block .= "
    <tr>
    <td colspan=3> </td>
    </tr>
    <tr>
    <td>Health Points</td>
    <td class=align_levels>$health</td>
    <td> </td>
    </tr>
    <tr>
    <td>Energy Points</td>
    <td class=align_levels>$energy</td>
    <td> </td>
    </tr>
    <tr>
    <td>Attack Combat Value</td>
    <td class=align_levels>$acv1</td>
    <td>$acv2</td>
    </tr>
    <tr>
    <td>Defense Combat Value</td>
    <td class=align_levels>$dcv1</td>
    <td>$dcv2</td>
    </tr>
    <tr>
    <td>Total Character Points</td>
    <td class=align_levels>$total_cp</td>
    <td> </td>
    </tr>
    </table><br>";
    
    }
    
    //gather defects
    $get_defects = "select * from scout_defects where identity = '$identity'";
    $get_defects_res = mysql_query($get_defects, $conn) or die(mysql_error());
    
    $display_block .= "
    
    <table cellpadding=3 cellspacing=3 border=0 width=90% align=center class=list_tables>
    <th colspan=3>Character Defects</th>";
    
    while ($defects_info = mysql_fetch_array($get_defects_res)) {
        $defects_id = $defects_info['id'];
        $defects_identity = $defects_info['identity'];
        $defects_id = $defects_info['defect_id'];
        $desc = $defects_info['desc'];
        $defects_level = $defects_info['level'];
        
        if($defects_info['desc'] != ""){
       $desc = "(" . $defects_info['desc'] . ")";
    }else{
       $desc = "";
    }
        
    $get_defects_names = "select * from defects where id = '$defects_id'";
    $get_defects_names_res = mysql_query($get_defects_names, $conn) or die(mysql_error());
    
    while ($defects_names_info = mysql_fetch_array($get_defects_names_res)) {
        $defects_names_id = $defects_names_info['id'];
        $defect = $defects_names_info['defect'];
        
    $display_block .= "
        
    <tr>
    <td>$defect $desc</td>
    <td>$defects_level</td>
    <td> </td>
    </tr>";
    
    }
    }
    
    $display_block .= "
    </table></td>";
    
    // gather attributes and sub-attributes
    $get_attributes = "select * from scout_attributes where identity = '$identity'";
    
    $get_attributes_res = mysql_query($get_attributes, $conn)
        or die(mysql_error());
    
    $display_block .= "
    <td valign=top>
    <table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables>    
    <th colspan=3>Character Attributes And Sub-Attributes</th>
    <tr>
    <td align=center><b>Attribute/Sub-Attribute</b></td>
    <td align=center><b>Level</td>
    <td align=center><b>Points</b></td>
    </tr>";
    
    while ($attributes_info = mysql_fetch_array($get_attributes_res)) {
        $attributes_id = $attributes_info['id'];
        $attribute_identity = $attributes_info['identity'];
        $attribute_id = $attributes_info['attribute_id'];
        $attribute_level = $attributes_info['level_id'];
    
    $get_attribute_names = "SELECT * FROM attributes WHERE id = '$attribute_id'";
    
    $get_attribute_names_res = mysql_query($get_attribute_names, $conn) or die(mysql_error());
        
    while ($attribute_names_info = mysql_fetch_array($get_attribute_names_res)) {
        $attribute_names_id = $attribute_names_info['id'];
        $attribute_names_attribute = $attribute_names_info['attribute'];
        $attributes_names_points = $attribute_names_info['points'];
        $attributes_points = ($attributes_names_points * $attribute_level);
    
        $display_block .= "
        
    <tr>
    <td>$attribute_names_attribute</td>
    

  3. Can someone help me with how I can update  two fields (available and username) in my table (scouts) when a user presses a button?

     

    I have the button set to go to this page when the press it:

     

    accept_character.php

     

    which will have the update code on it. I think I need to start like this:

     

    <?php
    
    $accept_scout = mysql_query("UPDATE scouts SET usename = '$_SESSION[userName]' AND available = '0' WHERE identity = '$identity'";
    
    ?>
    

     

    I want the username to be changed to the username that is logged in, which should be $_SESSION[userName]. I also want to change available to 0. I need it to change the record based on the identity of the profile they are viewing, which should be $identity. Is the above statement right?

  4. $display_block .= "
    <tr>
    <td class=indent>$sub_attribute_names_attribute</td>";    
    
    if ($sub_attributes_level_id == null) {
        $display_block .= "<td> </td>
        <td> </td></tr>";
        } else {
    $display_block .= "
    <td class=align_levels>$sub_attributes_level_id</td>
    <td class=align_levels>$sub_attributes_points</td></tr>";
    }
    
    //gather attacks
    $get_items = "select * from items where identity = '$identity' and acquired = 1 order by level asc";
    $get_items_res = mysql_query($get_items, $conn) or die(mysql_error());
    
    while ($items_info = mysql_fetch_array($get_items_res)) {
        $item_id = $items_info['id'];
        $item_identity = $items_info['identity'];
        $items = $items_info['item'];
        $item_desc = $items_info['desc'];
        $item_level = $items_info['level'];
        $item_points = ($sub_attribute_names_points * $item_level);
        
    if ($sub_attribute_names_attribute == 'Item Of Power') {
    $display_block .= "
    <tr>
    <td class=indent2>- $items</td>
    <td class=align_levels>$item_level</td>
    <td class=align_levels>$item_points</td>
    </tr>
    <tr>";
    
    }
    }
    
    }
    }
    
    //gather attacks
    $get_attacks = "select * from attacks where identity = '$identity' and level <= '$character_attack_level' and learned = 1 order by level desc";
    $get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error());
    
    while ($attacks_info = mysql_fetch_array($get_attacks_res)) {
        $attack_id = $attacks_info['id'];
        $attack_identity = $attacks_info['identity'];
        $attack = $attacks_info['attack'];
        $primary = $attacks_info['primary_attack'];
        $secondary = $attacks_info['secondary_attack'];
        $attack_level = $attacks_info['level'];
        $attack_points = ($sub_attribute_names_points * $attack_level);
        $learned = $attacks_info['learned'];
        
    //checks for primary and secondary attacks
        if($secondary == 1) $attack_points = 2;
    elseif($primary == 0 && $secondary == 0) $attack_points = 1;
    
    if ($sub_attribute_names_attribute == 'Sailor Scout Attack') {
    $display_block .= "
    <tr>
    <td class=indent2>- $attack</td>
    <td class=align_levels>$attack_level</td>
    <td class=align_levels>$attack_points</td>
    </tr>
    <tr>";
    
    }
    }
    
    //gather neutral attributes
    $get_neutral_attributes = "select * from scout_neutral_attributes where identity = '$identity'";
    $get_neutral_attributes_res = mysql_query($get_neutral_attributes, $conn) or die(mysql_error());
    
    while ($neutral_attributes_info = mysql_fetch_array($get_neutral_attributes_res)) {
        $neutral_attributes_id = $neutral_attributes_info['id'];
        $neutral_attributes_identity = $neutral_attributes_info['identity'];
        $neutral_attributes_attribute_id = $neutral_attributes_info['attribute_id'];
        $neutral_attributes_level_id = $neutral_attributes_info['level_id'];
        
    $get_neutral_attribute_names = "select * from neutral_attributes where id = '$neutral_attributes_attribute_id'";
    $get_neutral_attribute_names_res = mysql_query($get_neutral_attribute_names, $conn) or die(mysql_error());
    
    while ($neutral_attribute_names_info = mysql_fetch_array($get_neutral_attribute_names_res)) {
        $neutral_attribute_names_id = $neutral_attribute_names_info['id'];
        $neutral_attribute_names_attribute = $neutral_attribute_names_info['attribute'];
        $neutral_attribute_names_points = $neutral_attribute_names_info['points'];
        $neutral_attribute_points = ($neutral_attributes_level_id * $neutral_attribute_names_points);
        
    $display_block .= "
    <tr>
    <td>$neutral_attribute_names_attribute</td>
    <td class=align_levels>$neutral_attributes_level_id</td>
    <td class=align_levels>$neutral_attribute_points</td>
    </tr>";
    
    }
    }
    
    $display_block .= "
    </table></td></tr></table><br>";
    
    $display_block .= "
    <table border=0 width=100%>
    <tr>
    <td width=50% valign=top>
    <table>
    <tr>
    <td align=center><h1>Items Of Power</h1></td>";
    
    $get_items = "select * from items where identity = '$identity' and acquired = 1";
    $get_items_res = mysql_query($get_items, $conn) or die(mysql_error());
    
    while ($items_info = mysql_fetch_array($get_items_res)) {
        $items_id = $items_info['id'];
        $items_identity = $items_info['identity'];
        $item = $items_info['item'];
        $item_desc = nl2br($items_info['desc']);
        $item_level = $items_info['level'];
        $item_points = ($sub_attribute_names_points * $item_level);
        
    $display_block .= "
    <tr>
    <td class=hanging-indent>
    <i>$item --- </i><br>
    $item_desc</td></tr>";
    
    }
    
    $display_block .= "</table></td><td valign=top width=50%>
    <table>
    <tr>
    <td align=center><h1>Sailor Scout Attacks</td></tr>";
    
    //gather attacks
    $get_attacks = "select * from attacks where identity = '$identity' and learned = 1 order by level asc";
    $get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error());
    
    while ($attacks_info = mysql_fetch_array($get_attacks_res)) {
        $attack_id = $attacks_info['id'];
        $attack_identity = $attacks_info['identity'];
        $attack = $attacks_info['attack'];
        $attack_desc = nl2br($attacks_info['desc']);
        $primary = $attacks_info['primary_attack'];
        $secondary = $attacks_info['secondary_attack'];
        $attack_level = $attacks_info['level'];
        $attack_points = ($sub_attribute_names_points * $attack_level);
        
        $display_block .= "
    <tr>
    <td class=hanging-indent>
    <i>$attack --- </i><br>
    $attack_desc</td></tr>";
    
    }
    
    $display_block .= "</table></td></tr></table>";
    
    $display_block .= "<table border=0 cellpadding=3 cellspacing=3 width=100%>
        <tr>
        <td width=50% valign=top>
        <table>
        <tr>
        <td align=center><h1>Transformations</h1></td>
        </tr>";
    
    $get_transformations = "select * from transformations where identity = '$identity'";
    $get_transformations_res = mysql_query($get_transformations, $conn) or die(mysql_error());
    
    while ($transformation_info = mysql_fetch_array($get_transformations_res)) {
        $transformation_id = $transformation_info['id'];
        $transformation_identity = $transformation_info['identity'];
        $transformation = $transformation_info['transformation'];
        $transformation_desc = $transformation_info['desc'];
        $transformation_level = $transformation_info['level'];
        
        $display_block .= "
        <tr>
        <td class=hanging-indent>
        <i>$transformation --- </i><br>
        $transformation_desc</td></tr>";
        
        }
        
        $display_block .= "</table></td>
        <td width=50% valign=top>
        <table>
        <tr>
        <td align=center><h1>Attribute/Sub-Attribute Notes</h1></td></tr>
        <tr>
        <td>
        <ol>";
        
    //gather attributes and sub-attributes notes
    
    $get_sub_notes = "select * from scout_sub_attributes where identity = '$identity' and notes IS NOT NULL";
    $get_sub_notes_res = mysql_query($get_sub_notes, $conn) or die(mysql_error());
    
    while ($sub_notes_info = mysql_fetch_array($get_sub_notes_res)) {
        $sub_notes = nl2br($sub_notes_info['notes']);
        $sub_id = $sub_notes_info['sub_attribute_id'];
        
        $display_block.= "
        <li>$sub_notes</li>";
        
        }
        
    //gather neutral notes
    
    $get_neutral_notes = "select notes from scout_neutral_attributes where identity = '$identity' and notes IS NOT NULL";
    $get_neutral_notes_res = mysql_query($get_neutral_notes, $conn) or die(mysql_error());
    
    while ($neutral_notes_info = mysql_fetch_array($get_neutral_notes_res)) {
        $neutral_notes = nl2br($neutral_notes_info['notes']);
        
        $display_block .= "
        <li>$neutral_notes</li>";
        
        }
        
    //gather defect notes
    
    $get_defect_notes = "select notes from scout_defects where identity = '$identity' and notes IS NOT NULL";
    $get_defect_notes_res = mysql_query($get_defect_notes, $conn) or die(mysql_error());
    
    while ($defect_notes_info = mysql_fetch_array($get_defect_notes_res)) {
        $defect_notes = nl2br($defect_notes_info['notes']);
        
        $display_block .= "
        <li>$defect_notes</li>";
        
        }
        
        $display_block .= "</ol></table></td></tr></table>";
    
    ?>
    <html>
    <head>
    <title><?php print $identity; ?>'s Profile</title>
    <style type="text/css" media="screen">
    /*<![CDATA[*/
    @import url(global.css); 
    /*]]>*/
    </style>
    </head>
    <body>
    <!-- HEADER -->
    <h1 class="logo">Sailor Moon RPG</h1>
    <!-- /HEADER -->
    <?php include("topnav.php"); ?>
    <div id="main">
    <?php include("includes/log.php"); ?>
    <?php include("mainnav.php"); ?>
    <h1 align="center"><?php print $identity; ?></h1>
    <?php print $display_block; ?>
    </div>
    <?php include("bottomnav.php"); ?><!-- FOOTER -->
    <!-- FOOTER -->
    <div id="footer_wrapper">
    <div id="footer">
    <p>Sailor Moon and all characters
    are<br /> 
    trademarks of Naoko Takeuchi.</p>
    <p>Copyright © 2009 Liz Kula. All rights reserved.<br />
    A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
    <div id="foot-nav">
    <ul>
    <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
    <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
    </ul>
    </div>
    </div>
    </div>
    <!-- /FOOTER -->
    </body>
    </html>
    

  5. <?php
    
    session_start();
    
    //Access Tracking Snippet
    
    //set up static variables
    $page_title = "showprofile.php";
    $user_agent = getenv("HTTP_USER_AGENT");
    $date_accessed = date("Y-m-d");
    
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
        or die(mysql_error());
    $db = mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    //create and issue query
    $sql = "insert into access_tracker values
        ('', '$page_title', '$user_agent', '$date_accessed')";
    mysql_query($sql,$conn);
    ?>
    
    <?php
    //check for required info from the query string
    if (!$_GET['id']) {
        header("Location: listcharacters.php");
        exit;
    }
    
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
        or die(mysql_error());
    mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    //verify the topic exists
    $verify_topic = "select identity from scouts where
        id = $_GET[id]";
    $verify_topic_res = mysql_query($verify_topic, $conn)
        or die(mysql_error());
    
    if (mysql_num_rows($verify_topic_res) < 1) {
        //this character does not exist
        $display_block = "<p><em>You have selected an invalid character.
        Please <a href=\"listcharacters.php\">try again</a></em></p>";
    } else {
        //gather rest of profile
        $get_posts = "select *, date_format(create_time, '%b %e %Y at %r') as fmt_scout_create_time from scouts where id = $_GET[id]";
            
        $get_posts_res = mysql_query($get_posts, $conn) or die(mysql_error());
        
        //create the display string
        $display_block = "
        <table cellpadding=3 cellspacing=1 border=0 class=list_tables>";
        
        while ($posts_info = mysql_fetch_array($get_posts_res)) {
            $post_id = $posts_info['id'];
            $identity = ucwords($posts_info['identity']);
            $character_create_time = $posts_info['fmt_scout_create_time'];
            $username = $posts_info['username'];
            $name = ucwords(strtolower($posts_info['name']));
            $element_of_influence = $posts_info['element_of_influence'];
            $age = $posts_info['age'];
            $birth_month = $posts_info['birth_month'];
            $birth_date = $posts_info['birth_date'];
            $birth_year = $posts_info['birth_year'];
            $height_feet = $posts_info['height_feet'];
            $height_inches = $posts_info['height_inches'];
            $blood_type = strtoupper($posts_info['blood_type']);
            $hobbies = ucwords(strtolower($posts_info['hobbies']));
            $favorite_color = ucwords(strtolower($posts_info['favorite_color']));
            $favorite_gemstone = ucwords(strtolower($posts_info['favorite_gemstone']));
            $favorite_food = ucwords(strtolower($posts_info['favorite_food']));
            $least_favorite_food = ucwords(strtolower($posts_info['least_favorite_food']));
            $favorite_school_subject = ucwords(strtolower($posts_info['favorite_school_subject']));
            $least_favorite_school_subject = ucwords(strtolower($posts_info['least_favorite_school_subject']));
            $strengths = ucwords(strtolower($posts_info['strengths']));
            $weaknesses = ucwords(strtolower($posts_info['weaknesses']));
            $goal = ucfirst($posts_info['goal']);
            $mission = ucfirst($posts_info['mission']);
            $biography = nl2br($posts_info['biography']);
            $biography = str_replace("\n", "<p>", $biography );
            $getMonth = date('F', mktime(0, 0, 0, $birth_month));
            $character_attack_level = $posts_info['attack_level'];
            
        $get_images = "select * from upload where identity = '$identity'";
        $get_images_res = mysql_query($get_images, $conn) or die(mysql_error());
        
        while ($images_info = mysql_fetch_array($get_images_res)) {
            $image_id = $images_info['id'];
            $image_identity = $images_info['identity'];
            $image_name = $images_info['name'];
            $image_type = $images_info['type'];
            $image_size = $images_info['size'];
            $image_content = $images_info['content'];
            
            //add to display
            $display_block .= "
            <tr>
            <td width=24% valign=top><strong>Character Name:</strong></td>
            <td width=55% valign=top>$name</td>
            <td align=center valign=top rowspan=18><img src='download.php?id=$image_id'></td>
            </tr>
            <tr>
            <td><strong>Element Of Influence:</strong></td>
            <td>$element_of_influence</td>
            </tr>
            <tr>
            <td><strong>Age:</strong></td>
            <td>$age</td>
            </tr>
            <tr>
            <td><strong>Date Of Birth:</strong></td>
            <td>$getMonth $birth_date, $birth_year</td>
            </tr>
            <tr>
            <td><strong>Height:</strong></td>
            <td>$height_feet feet $height_inches inches</td>
            </tr>
            <tr>
            <td><strong>Blood Type:</strong></td>
            <td>$blood_type</td>
            </tr>
            <tr>
            <td><strong>Hobbies:</strong></td>
            <td>$hobbies</td>
            </tr><tr>
            <td><strong>Favorite Color:</strong></td>
            <td>$favorite_color</td>
            </tr>
            <tr>
            <td><strong>Favorite Gemstone:</strong></td>
            <td>$favorite_gemstone</td>
            </tr>
            <tr>
            <td><strong>Favorite Food:</strong></td>
            <td>$favorite_food</td>
            </tr>
            <tr>
            <td><strong>Least Favorite Food:</strong></td>
            <td>$least_favorite_food</td>
            </tr>
            <tr>
            <td><strong>Favorite School Subject:</strong></td>
            <td>$favorite_school_subject</td>
            </tr>
            <tr>
            <td><strong>Least Favorite School Subject:</strong></td>
            <td>$least_favorite_school_subject</td>
            </tr>
            <tr>
            <td><strong>Strengths:</strong></td>
            <td>$strengths</td>
            </tr>
            <tr>
            <td><strong>Weaknesses:</strong></td>
            <td>$weaknesses</td>
            </tr>
            <tr>
            <td><strong>Goal:</strong></td>
            <td>$goal...</td>
            </tr>
            <tr>
            <td><strong>Mission:</strong></td>
            <td>$mission.</td>
            </tr>
            <td> </td>
            <td> </td>
            </tr>
            <tr>
            <td align=right colspan=3>Created By: <strong>$username</strong><br>
            Created On: <em>$character_create_time</em></td>
            </tr>";
            }
            
            //close up the table
            $display_block .= "</table><br>
            <p>$biography</p><br>";
    }
    }
    
    //gather stats and derived values; fix where statement
    
    $get_stats = "select * from stats where identity = '$identity'";
    
    $get_stats_res = mysql_query($get_stats, $conn) or die(mysql_error());
    
    $display_block .= "
    <table cellpadding=3 cellspacing=3 border=0 width=100%>";
    
    while ($stats_info = mysql_fetch_array($get_stats_res)) {
            $body = $stats_info['body'];
            $mind = $stats_info['mind'];
            $soul = $stats_info['soul'];
            
    $display_block .= "
    <tr>
    <td valign=top>
    <table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables>
    <th colspan=3>Stats And Derived Values</th>
    <tr>
    <td>Body</td>
    <td class=align_levels>$body</td>
    <td> </td>
    </tr>
    <tr>
    <td>Mind</td>
    <td class=align_levels>$mind</td>
    <td> </td>
    </tr>
    <tr>
    <td>Soul</td>
    <td class=align_levels>$soul</td>
    <td> </td>
    </tr>";
    }
    
    //gather derived values
    $get_derived = "select * from derived_values where identity = '$identity'";
    
    $get_derived_res = mysql_query($get_derived, $conn) or die(mysql_error());
    
    while ($derived_info = mysql_fetch_array($get_derived_res)) {
        $health = $derived_info['health'];
        $energy = $derived_info['energy'];
        $acv1 = $derived_info['acv1'];
        $acv2 = $derived_info['acv2'] . ' (for Sailor Scout Attack)';
        $dcv1 = $derived_info['dcv1'];
        $dcv2 = $derived_info['dcv2'] . ' (for Sailor Scout Attack)';
        $total_cp = $derived_info['total_cp'];
        
    if($health == 0 || $health == '0' || $health == null){$GLOBALS['health'] = "";}
    if($energy == 0 || $energy== '0' || $energy == null){$GLOBALS['energy'] = "";}
    if($acv1 == 0 || $acv1 == '0' || $acv1 == null){$GLOBALS['acv1'] = "";}
    if($acv2 == 0 || $acv2 == '0' || $acv2 == null){$GLOBALS['acv2'] = "";}
    if($dcv1 == 0 || $dcv1 == '0' || $dcv1 == null){$GLOBALS['dcv1'] = "";}
    if($dcv2 == 0 || $dcv2 == '0' || $dcv2 == null){$GLOBALS['dcv2'] = "";}
    if($total_cp == 0 || $total_cp == '0' || $total_cp== null){$GLOBALS['total_cp'] = "";}
    
    $display_block .= "
    <tr>
    <td colspan=3> </td>
    </tr>
    <tr>
    <td>Health Points</td>
    <td class=align_levels>$health</td>
    <td> </td>
    </tr>
    <tr>
    <td>Energy Points</td>
    <td class=align_levels>$energy</td>
    <td> </td>
    </tr>
    <tr>
    <td>Attack Combat Value</td>
    <td class=align_levels>$acv1</td>
    <td>$acv2</td>
    </tr>
    <tr>
    <td>Defense Combat Value</td>
    <td class=align_levels>$dcv1</td>
    <td>$dcv2</td>
    </tr>
    <tr>
    <td>Total Character Points</td>
    <td class=align_levels>$total_cp</td>
    <td> </td>
    </tr>
    </table><br>";
    
    }
    
    //gather defects
    $get_defects = "select * from scout_defects where identity = '$identity'";
    $get_defects_res = mysql_query($get_defects, $conn) or die(mysql_error());
    
    $display_block .= "
    
    <table cellpadding=3 cellspacing=3 border=0 width=90% align=center class=list_tables>
    <th colspan=3>Character Defects</th>";
    
    while ($defects_info = mysql_fetch_array($get_defects_res)) {
        $defects_id = $defects_info['id'];
        $defects_identity = $defects_info['identity'];
        $defects_id = $defects_info['defect_id'];
        $desc = $defects_info['desc'];
        $defects_level = $defects_info['level'];
        
        if($defects_info['desc'] != ""){
       $desc = "(" . $defects_info['desc'] . ")";
    }else{
       $desc = "";
    }
        
    $get_defects_names = "select * from defects where id = '$defects_id'";
    $get_defects_names_res = mysql_query($get_defects_names, $conn) or die(mysql_error());
    
    while ($defects_names_info = mysql_fetch_array($get_defects_names_res)) {
        $defects_names_id = $defects_names_info['id'];
        $defect = $defects_names_info['defect'];
        
    $display_block .= "
        
    <tr>
    <td>$defect $desc</td>
    <td>$defects_level</td>
    <td> </td>
    </tr>";
    
    }
    }
    
    $display_block .= "
    </table></td>";
    
    // gather attributes and sub-attributes
    $get_attributes = "select * from scout_attributes where identity = '$identity'";
    
    $get_attributes_res = mysql_query($get_attributes, $conn)
        or die(mysql_error());
    
    $display_block .= "
    <td valign=top>
    <table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables>    
    <th colspan=3>Character Attributes And Sub-Attributes</th>
    <tr>
    <td align=center><b>Attribute/Sub-Attribute</b></td>
    <td align=center><b>Level</td>
    <td align=center><b>Points</b></td>
    </tr>";
    
    while ($attributes_info = mysql_fetch_array($get_attributes_res)) {
        $attributes_id = $attributes_info['id'];
        $attribute_identity = $attributes_info['identity'];
        $attribute_id = $attributes_info['attribute_id'];
        $attribute_level = $attributes_info['level_id'];
    
    $get_attribute_names = "SELECT * FROM attributes WHERE id = '$attribute_id'";
    
    $get_attribute_names_res = mysql_query($get_attribute_names, $conn) or die(mysql_error());
        
    while ($attribute_names_info = mysql_fetch_array($get_attribute_names_res)) {
        $attribute_names_id = $attribute_names_info['id'];
        $attribute_names_attribute = $attribute_names_info['attribute'];
        $attributes_names_points = $attribute_names_info['points'];
        $attributes_points = ($attributes_names_points * $attribute_level);
    
        $display_block .= "
        
    <tr>
    <td>$attribute_names_attribute</td>
    <td class=align_levels>$attribute_level</td>
    <td class=align_levels>$attributes_points</td>
    </tr>";
    
    }
    }
    
    $get_sub_attributes = "select * from scout_sub_attributes where identity = '$identity'";
    $get_sub_attributes_res = mysql_query($get_sub_attributes, $conn) or die(mysql_error());
    
    while ($sub_attributes_info = mysql_fetch_array($get_sub_attributes_res)) {
        $sub_attributes_id = $sub_attributes_info['id'];
        $sub_attributes_identity = $sub_attributes_info['identity'];
        $sub_attributes_attribute_id = $sub_attributes_info['sub_attribute_id'];
        $sub_attributes_level_id = $sub_attributes_info['level_id'];
        $sub_attributes_notes = $sub_attributes_info['notes'];
        
    $get_sub_attribute_names = "select * from sub_attributes where id = '$sub_attributes_attribute_id'";
    $get_sub_attribute_names_res = mysql_query($get_sub_attribute_names, $conn) or die(mysql_error());
    
    while ($sub_attribute_names_info = mysql_fetch_array($get_sub_attribute_names_res)) {
        $sub_attribute_names_id = $sub_attribute_names_info['id'];
        $sub_attribute_names_attribute = $sub_attribute_names_info['sub_attribute'];
        $sub_attribute_names_points = $sub_attribute_names_info['points'];
        $sub_attributes_points = ($sub_attribute_names_points * $sub_attributes_level_id);
    

  6. This is going to be a strange question, but is there some kind of way to set a code to make your page access a specific font? I mean, you know like if someone doesn't have the font you want to use on your page, then it won't display it, but I was wondering if there was a way maybe to have a font saved on your database and have the php code access it to ensure that the viewer sees the font you want to use. Is this possible or something like this? Is there a way around this? Or code you maybe have the user asked to install it? Is there a way to not have to make them install it?

  7. I tried adding this to the page that displays the form results, but nothing is getting inserted into my table. What am I doing wrong? I changed the form method to post instead of get as well, and it isn't working. :-(

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Form Processor</title>
    <meta http-equiv="content-type" content="text/html;
    charset=iso-8859-1" />
    <link rel="stylesheet" href="js_styles.css" type="text/css" />
    </head>
    <body>
    
    <script type="text/javascript">
    /* <![CDATA[ */
    document.write("<h1>Your form has been submitted!</h1><h2>You entered the following data:</h2>");
    var formData = location.search;
    formData = formData.substring(1, formData.length);
    while (formData.indexOf("+") != -1) {
        formData = formData.replace("+", " ");
    }
    formData = unescape(formData);
    var formArray = formData.split("&");
    for (var i=0; i < formArray.length; ++i) {
        document.writeln(formArray[i] + "<br />");
    }
    /* ]]> */
    </script>
    
    <?php 
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
        or die(mysql_error());
    $db = mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    $insert_email = "insert into testemail values ('$_POST[sender_name]', '$_POST[sender_email]', '$_POST[recipient_name]', '$_POST[recipient_email]', '$_POST[recipients]', '$_POST[subject]', '$_POST[message]')";
    mysql_query($insert_email, $conn) or die(mysql_error());
    
    ?>
    
    </body>
    </html>
    
    

  8. I have the following code:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>E-Mail Form</title>
    <link rel="stylesheet" href="js_styles.css" type="text/css" />
    <meta http-equiv="content-type"
    content="text/html; charset=iso-8859-1" />
    <script type="text/javascript">
    /* <![CDATA{ */
    function validateSubmission() {
    var retValue = true;
    
    if (document.forms[0].subject.value.length > 40) {
        window.alert("The subject must be 40 characters or less!");
        return false;
    }
    
    else if (document.forms[0].sender_email.value == "" || document.forms[0].recipient_email.value == "" || document.forms[0].subject.value == "") {
    window.alert("You did not fill in one of the following required fields: sender e-mail, recipient e-mail, or subject.");
    retValue = false;
    }
    
    if (retValue == false)
        return retValue;
    retValue = validateEmail(document.forms[0].sender_email);
    if (retValue == false)
        return retValue;
        
    /*retValue = validateEmail(document.forms[0].recipient_email);
    if (retValue == false)
        return retValue;*/
    /*retValue = compareAddresses(document.forms[0].sender_email, document.forms[0].recipient_email);
    return retValue;*/
    
    }
    
    function validateEmail(formObject) {
        var email = formObject.value;
        if (email.search(/@/) == -1 || email.lastIndexOf(".") == -1) {
            window.alert("One or more of the e-mail addresses you entered does not appear to be valid.");
            return false;
        }
        formObject.value = email.toLowerCase();
        return true;
    }
    
    /*function compareAddresses(senderObject, recipientObject) {
        var senderEmail = senderObject.value;
        var recipientEmail = recipientObject.value;
        senderEmail = senderEmail.toLowerCase();
        recipientEmail = recipientEmail.toLowerCase();
        if (senderEmail.localeCompare(recipientEmail) == 0) {
            window.alert("You entered the same e-mail address for sender and recipient.");
        return false;
    }
    else
        return true;
    }*/
    
    function addRecipient() {
        if (document.forms[0].recipient_name.value == "" || document.forms[0].recipient_email.value == "")
            window.alert("You must enter the recipient's name and e-mail address.");
            
        else {
            retValue = validateEmail(
            document.forms[0].recipient_email);
            if (retValue ==  false)
            return retValue;
            if (document.forms[0].recipients.options[0] && document.forms[0].recipients.options[0].value == "recipients")
            document.forms[0].recipients.options[0] = null;
            var nextRecipient = document.forms[0].recipients.options.length;
            var createRecipient = new Option (document.forms[0].recipient_name.value + ", " + document.forms[0].recipient_email.value);
            document.forms[0].recipients.options[nextRecipient] = createRecipient;
            var recipientsArray = new Array();
            for (var i=0; i<document.forms[0].recipients.options.length; ++i) {
                recipientsArray.push(document.forms[0].recipients.options[i].value);
            }
            for (var j=0; j<recipientsArray.length; ++j) {
                var createRecipient = new Option(recipientsArray[j]);
                document.forms[0].recipients.options[j] = createRecipient;
            }
            }
            
        }
    function deleteRecipient() {
    var selectedIndex = document.forms[0].recipients.selectedIndex;
    var recipientInfo = document.forms[0].recipients.options[selectedIndex] = null;
    }
    /* ]]> */
    </script>
    </head>
    <body>
    <form action="FormProcessor.html" method="get" onsubmit="return validateSubmission()">
    <table frame="border" rules="cols" >
    <tr>
    <td valign="top">
    <h2>Sender</h2>
    <p>Name<br />
    <input type="text" name="sender_name" size="40" /></p>
    <p>E-Mail Address<br />
    <input type="text" name="sender_email" size="40" /></p>
    <hr /><h2>Recipients</h2>
    <p>Name<br />
    <input type="text" name="recipient_name" size="40" /></p>
    <p>E-Mail Address<br />
    <input type="text" name="recipient_email" size="40" /></p>
    <p><input type="button" value="Add" onclick="addRecipient()"  />  <input type="button" value="Remove" onclick="deleteRecipient()"  />  <input type="button" value="Update" onclick="updateSelectedRecipient()"  /></p>
    <select name="recipients" size="4" style="width: 265px" onclick="getRecipientInfo()">
    <option value="recipients">Recipients</option>
    </select>
    </td>
    <td valign="top">
    <h2>Message Details</h2>
    <p>Subject<br />
    <input type="text" name="subject" size="53" /></p>
    <p>Message<br />
    <textarea name="message" rows="14" cols="40"></textarea></p>
    <p style="text-align: center"><input type="submit" value="Send" /><input type="reset" />
    <input type="hidden" name="recipientsList" /></p>
    </td></tr>
    </table>
    </form>
    </body>
    </html>
    

     

    And here is the page that is displaying the results of the form:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Form Processor</title>
    <meta http-equiv="content-type" content="text/html;
    charset=iso-8859-1" />
    <link rel="stylesheet" href="js_styles.css" type="text/css" />
    </head>
    <body>
    <script type="text/javascript">
    /* <![CDATA[ */
    document.write("<h1>Your form has been submitted!</h1><h2>You entered the following data:</h2>");
    var formData = location.search;
    formData = formData.substring(1, formData.length);
    while (formData.indexOf("+") != -1) {
        formData = formData.replace("+", " ");
    }
    formData = unescape(formData);
    var formArray = formData.split("&");
    for (var i=0; i < formArray.length; ++i) {
        document.writeln(formArray[i] + "<br />");
    }
    /* ]]> */
    </script>
    </body>
    </html>
    
    
    

     

    How can I insert the results being generated into the select list into my table in my database?

  9. I have the following page and script:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Gosselin Gazette Subscription Form</title>
    <meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="js_styles.css" type="text/css" />
    <script type="text/javascript">
    /*<![CDATA[ */
    function checkForNumber(fieldValue) {
       var numberCheck = isNaN(fieldValue);
       if (numberCheck == true) {
          window.alert("You must enter a numeric value!");
          return false;
       }
    }
    
    function confirmPassword() {
       if (document.forms[0].password_confirm.value
          != document.forms[0].password.value) {
          window.alert("You did not enter the same password!");
       document.forms[0].password.focus();
       }
    }
    
    function noDelivery() {
       for (var i=0;i<document.forms[0].delivery.length;++i) {
          if (document.forms[0].delivery[i].checked == true)
             document.forms[0].delivery[i].checked = false;
       }
    }
    function noSunday() {
       for(var i=0;i<document.forms[0].sunday.length;++i) {
          if (document.forms[0].sunday[i].checked == true)
             document.forms[0].sunday[i].checked = false;
       }
    }
    
    function sameShippingInfo() {
       if (document.forms[0].elements[5].checked == true) {
          document.forms[0].name_shipping.value
             = document.forms[0].name_billing.value;
          document.forms[0].address_shipping.value
             = document.forms[0].address_billing.value;
          document.forms[0].city_shipping.value
             = document.forms[0].city_billing.value;
          document.forms[0].state_shipping.value
             = document.forms[0].state_billing.value;
          document.forms[0].zip_shipping.value
             = document.forms[0].zip_billing.value;
       }
       else {
          document.forms[0].name_shipping.value = "";
          document.forms[0].address_shipping.value = "";
          document.forms[0].city_shipping.value = "";
          document.forms[0].state_shipping.value = "";
          document.forms[0].zip_shipping.value = "";
       }
    }
    
    function addMagazine() {
        if (document.forms[0].magazines.options[0]
            && (document.forms[0].magazines.options[0].value == "none"))
                    document.forms[0].magazines.options[0] = null;
       if (document.forms[0].elements[31].value == "")
          window.alert("You must enter a magazine name.");
       else {
          var magazine = new Option();
          magazine.text = document.forms[0].elements[31].value;
          magazine.value = document.forms[0]
             .elements[31].value;
          nextItem = document.forms[0].magazines.length;
          document.forms[0].magazines.options[nextItem]
             = magazine;
          document.forms[0].elements[31].value = "";
       }
    }
    function deleteMagazine() {
       var selectedItem =
          document.forms[0].magazines.selectedIndex;
       if (selectedItem == -1)
          window.alert(
             "You must select a magazine name in the list.");
       else
          document.forms[0].magazines.remove(selectedItem);
    }
    
    function confirmSubmit() {
        if (document.forms[0].name_billing == ""
            || document.forms[0].address_billing.value == ""
            || document.forms[0].city_billing.value == ""
            || document.forms[0].state_billing.value == ""
            || document.forms[0].zip_billing.value == "") {
            window.alert("You must enter your billing information.");
            return false;
        }
        else if (document.forms[0].name_shipping.value == ""
            || document.forms[0].address_shipping.value == ""
            || document.forms[0].city_shipping.value == ""
            || document.forms[0].state_shipping.value == ""
            || document.forms[0].zip_shipping.value == "") {
            window.alert("You must enter your shipping information.");
            return false;
        }
        else if (document.forms[0].password.value == ""
            || docuemnt.forms[0].password_confirm.value == "") {
            window.alert("You must enter a password.");
            return false;
        }
        
    //not working
    var deliverySelected = false;
    for (var i=0; i<8; ++i) {
        if (document.forms[0].delivery[i].checked == true) {
            deliverySelected = true;
            break;
        }
    }
    
    for (var j=0; j<2; ++j) {
        if (document.forms[0].sunday[j].checked == true) {
            deliverySelected = true;
            break;
        }
    }
    
    if (deliverySelected != true) {
        window.alert("You must select a delivery rate option.");
        return false;
    }
    //end not working
    
    for (var k=0; k<document.forms[0].magazines.length; ++k) 
        document.forms[0].magazines.options[k].selected = true
    }
        return true;
    }
    
    function confirmReset() {
        var resetForm = window.confirm("Are you sure you want to reset the form?");
        if (resetForm == true)
            return true;
        return false;
    }
    
    /*]]> */
    </script>
    </head>
    
    <body>
    <h1>Gosselin Gazette Subscription Form</h1>
    <h2>Customer Information</h2>
    <form action="FormProcessor.html" method="get"
    enctype="application/x-www-form-urlencoded" onsubmit="return confirmSubmit();" onreset="return confirmReset();">
    <table border="0">
    <tr>
    <td valign="top"><h3>Billing Information</h3>
    <p>Name<br />
    <input type="text" name="name_billing" size="50" /></p>
    <p>Address<br />
    <input type="text" name="address_billing" size="50" /></p>
    <p>City, State, Zip<br />
    <input type="text" name="city_billing" size="34" />
    <input type="text" name="state_billing" size="2" maxlength="2" />
    <input type="text" name="zip_billing" size="10"
    maxlength="10" onchange="return checkForNumber(this.value);" /></p>
    <p><input type="checkbox" onclick="sameShippingInfo();" />
    Same shipping information</p></td>
    <td valign="top">
    <h3>Shipping Information</h3>
    <p>Name<br />
    <input type="text" name="name_shipping" size="50" /></p>
    <p>Address<br />
    <input type="text" name="address_shipping" size="50" /></p>
    <p>City, State, Zip<br />
    <input type="text" name="city_shipping" size="34" />
    <input type="text" name="state_shipping" size="2"
    maxlength="2" />
    <input type="text" name="zip_shipping" size="10"
    maxlength="5" onchange="return checkForNumber(this.value);" /></p></td></tr>
    </table>
    <p>Telephone</p>
    <p>(<input type="text" name="area" size="3" maxlength="3" />)
    <input type="text" name="exchange" size="3" maxlength="3" />
    <input type="text" name="phone" size="4" maxlength="4" /></p>
    <p>Enter a password that you can use to manage your subscription online:</p>
    <p><input type="password" name="password" size="50" /></p>
    <p>Type the password again to confirm it.</p>
    <p><input type="password" name="password_confirm" size="50"
    onblur="confirmPassword();" /></p>
    <h3>Delivery Rates</h3>
    <table border="0">
    <colgroup align="left" width="150" />
    <colgroup span="4" align="center" width="130" />
    <tr><th> </th>
    <th>4 weeks</th>
    <th>13 weeks</th>
    <th>26 weeks</th>
    <th>52 weeks</th></tr>
    <tr><td><strong>Mon-Sat</strong></td>
    <td><input type="radio" name="delivery"
    value="12.60" onclick="noSunday();" />$12.60</td>
    <td><input type="radio" name="delivery"
    value="40.95" onclick="noSunday();" />$40.95</td>
    <td><input type="radio" name="delivery"
    value="81.90" onclick="noSunday();" />$81.90</td>
    <td><input type="radio" name="delivery"
    value="156.00" onclick="noSunday();" />$156.00</td></tr>
    <tr><td><strong>Every Day</strong></td>
    <td><input type="radio" name="delivery"
    value="13.56" onclick="noSunday();" />$13.56</td>
    <td><input type="radio" name="delivery"
    value="44.07" onclick="noSunday();" />$44.07</td>
    <td><input type="radio" name="delivery"
    value="88.14" onclick="noSunday();" />$88.14</td>
    <td><input type="radio" name="delivery"
    value="159.74" onclick="noSunday();" />$159.74</td></tr>
    </table>
    <p><strong>Sundays only ($3.50 per week)</strong>
    <input type="radio" name="sunday" value="weekly"
    onclick="noDelivery();" />Bill me weekly
    <input type="radio" name="sunday" value="monthly"
    onclick="noDelivery();" />Bill me monthly</p>
    <p>Do you subscribe to any other newspapers?</p>
    <p><input type="checkbox" name="newspapers"
    value="nytimes" />New York Times<br />
    <input type="checkbox" name="newspapers"
    value="bostonglobe" />Boston Globe<br />
    <input type="checkbox" name="newspapers"
    value="sfchronicle" />San Francisco Chronicle<br />
    <input type="checkbox" name="newspapers"
    value="miamiherald" />Miami Herald<br />
    <input type="checkbox" name="newspapers"
    value="other" />Other</p>
    <p>Do you subscribe to any magazines?</p>
    <p>Magazine <input type="text" size="68" /></p>
    <p><input type="button" value="Add Magazine"
    onclick="addMagazine();" style="width: 120px" />
    <input type="button" value="Delete Magazine"
    onclick="deleteMagazine()" style="width: 120px" />
    <input type="button" value="Clear List"
    onclick="document.forms[0].magazines.options.length = 0;"
    style="width: 120px" />
    <input type="button" value="Change Magazine"
    onclick="changeMagazine()" style="width: 120px" /></p>
    <p><select name="magazines" multiple="multiple"
    size="10" style="width: 500px">
    <option value="none">Enter the magazine you subscribe
    to</option>
    </select></p>
    <p><input type="image" alt="Graphical image of a subscribe button" src="subscribe.gif" /></p>
    <p><input type="reset" /></p>
    </form>
    </body>
    </html>
    

     

    But for some reason function for validating the radio buttons (I have it marked s not working) aren't working. Can anyone help me figure out why? Also, upon submission, I have a page displaying the results, but the select list options are not showing up. Here is the formprocessor page:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Form Processor</title>
    <meta http-equiv="content-type" content="text/html;
    charset=iso-8859-1" />
    <link rel="stylesheet" href="js_styles.css" type="text/css" />
    </head>
    <body>
    <script type="text/javascript">
    /* <![CDATA[ */
    document.write("<h1>Your form has been submitted!</h1><h2>You entered the following data:</h2>");
    var formData = location.search;
    formData = formData.substring(1, formData.length);
    while (formData.indexOf("+") != -1) {
        formData = formData.replace("+", " ");
    }
    formData = unescape(formData);
    var formArray = formData.split("&");
    for (var i=0; i < formArray.length; ++i) {
        document.writeln(formArray[i] + "<br />");
    }
    /* ]]> */
    </script>
    </body>
    </html>
    

     

    Can anyone tell me why the options we add to the select list aren't showing up upon submission?

  10. Here is the second page that displays the results:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Table Add Row - new window</title>
    <script language="JavaScript">
    <!--
    function printToPage()
    {
         var pos;
         var searchStr = window.location.search;
         var searchArray = searchStr.substring(1,searchStr.length).split('&');
         var htmlOutput = '';
         for (var i=0; i<searchArray.length; i++) {
             htmlOutput += searchArray[i] + '<br />';
         }
         return(htmlOutput);
    }
    //-->
    </script>
    </head>
    
    <body>
    <b>MREDKJ's Table Add Row</b>
    <br />
    Below should be the name/value pairs that were submitted:
    <p>
    <script language="JavaScript">
    <!--
    document.write(printToPage());
    //-->
    </script>
    
    </p>
    </body>
    </html>
    

     

    And here is the full JavaScript just in case I added anything I forgot about:

     

    
    
    // tabledeleterow.js version 1.2 2006-02-21
    // mredkj.com
    
    // CONFIG notes. Below are some comments that point to where this script can be customized.
    // Note: Make sure to include a <tbody></tbody> in your table's HTML
    
    var INPUT_NAME_PREFIX = 'option'; // this is being set via script
    var RADIO_NAME = 'totallyrad'; // this is being set via script
    var TABLE_NAME = 'tblSample'; // this should be named in the HTML
    var ROW_BASE = 1; // first number (for display)
    var hasLoaded = false;
    
    window.onload=fillInRows;
    
    function fillInRows()
    {
         hasLoaded = true;
         addRowToTable();
         addRowToTable();
    }
    
    // CONFIG:
    // myRowObject is an object for storing information about the table rows
    function myRowObject(one, two, three, four)
    {
         this.one = one; // text object
         this.two = two; // input text object
         this.three = three; // input checkbox object
         this.four = four; // input radio object
    }
    
    /*
      * insertRowToTable
      * Insert and reorder
      */
    function insertRowToTable()
    {
         if (hasLoaded) {
             var tbl = document.getElementById(TABLE_NAME);
             var rowToInsertAt = tbl.tBodies[0].rows.length;
             for (var i=0; i<tbl.tBodies[0].rows.length; i++) {
                 if (tbl.tBodies[0].rows[i].myRow && tbl.tBodies[0].rows[i].myRow.four.getAttribute('type') == 'radio' && tbl.tBodies[0].rows[i].myRow.four.checked) {
                     rowToInsertAt = i;
                     break;
                 }
             }
             addRowToTable(rowToInsertAt);
             reorderRows(tbl, rowToInsertAt);
         }
    }
    
    /*
      * addRowToTable
      * Inserts at row 'num', or appends to the end if no arguments are passed in. Don't pass in empty strings.
      */
    function addRowToTable(num)
    {
         if (hasLoaded) {
             var tbl = document.getElementById(TABLE_NAME);
             var nextRow = tbl.tBodies[0].rows.length;
             var iteration = nextRow + ROW_BASE;
             if (num == null) { 
                 num = nextRow;
             } else {
                 iteration = num + ROW_BASE;
             }
             
             // add the row
             var row = tbl.tBodies[0].insertRow(num);
             
             // CONFIG: requires classes named classy0 and classy1
             row.className = 'classy' + (iteration % 2);
         
             // CONFIG: This whole section can be configured
             
             // cell 0 - text
             var cell0 = row.insertCell(0);
             var textNode = document.createTextNode(iteration);
             cell0.appendChild(textNode);
             
             // cell 1 - input text
             //var cell1 = row.insertCell(1);
             //var txtInp = document.createElement('input');
             //txtInp.setAttribute('type', 'text');
             //txtInp.setAttribute('name', INPUT_NAME_PREFIX + iteration);
             //txtInp.setAttribute('size', '40');
             //txtInp.setAttribute('value', iteration); // iteration included for debug purposes
             //cell1.appendChild(txtInp);
             
             var cell1 = row.insertCell(1);
             var txtInp = document.createElement('select');
             //txtInp.setAttribute('value', 'name');
             //first option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Animal Guardian");
                     theOption.appendChild(theText);
                     theOption.setAttribute('name', INPUT_NAME_PREFIX + iteration);
                     txtInp.setAttribute('value', iteration); // iteration included for debug purposes
                     txtInp.appendChild(theOption);
                     
             //second option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Combined Attacks");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Combined Attacks');
                     txtInp.appendChild(theOption);
                     
             //third option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Elemental Control");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Elemental Control');
                     txtInp.appendChild(theOption);
                     
             //fourth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Emotional Control");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Emotional Control');
                     txtInp.appendChild(theOption);
                     
             //fifth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Item Of Power");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Item Of Power');
                     txtInp.appendChild(theOption);
                     
             //sixth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Knight Attack");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','index2');
                     txtInp.appendChild(theOption);
                     
             //seventh option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Rejuvenation");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','index2');
                     txtInp.appendChild(theOption);
                     
             //eighth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Scout Attack");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','index2');
                     txtInp.appendChild(theOption);
    
             //txtInp.setAttribute('size', '5');
             
             cell1.appendChild(txtInp, theOption);
             
             // cell 2 - input button
             var cell2 = row.insertCell(2);
             var btnEl = document.createElement('input');
             btnEl.setAttribute('type', 'button');
             btnEl.setAttribute('value', 'Delete');
             btnEl.onclick = function () {deleteCurrentRow(this)};
             cell2.appendChild(btnEl);
             
             // cell 3 - input checkbox
             var cell3 = row.insertCell(3);
             var cbEl = document.createElement('input');
             cbEl.setAttribute('type', 'checkbox');
             cell3.appendChild(cbEl);
             
             // cell 4 - input radio
             var cell4 = row.insertCell(4);
             var raEl;
             try {
                 raEl = document.createElement('<input type="radio" name="' + RADIO_NAME + '" value="' + iteration + '">');
                 var failIfNotIE = raEl.name.length;
             } catch(ex) {
                 raEl = document.createElement('input');
                 raEl.setAttribute('type', 'radio');
                 raEl.setAttribute('name', RADIO_NAME);
                 raEl.setAttribute('value', iteration);
             }
             cell4.appendChild(raEl);
             
             // Pass in the elements you want to reference later
             // Store the myRow object in each row
             row.myRow = new myRowObject(textNode, txtInp, cbEl, raEl);
         }
    }
    
    // CONFIG: this entire function is affected by myRowObject settings
    // If there isn't a checkbox in your row, then this function can't be used.
    function deleteChecked()
    {
         if (hasLoaded) {
             var checkedObjArray = new Array();
             var cCount = 0;
         
             var tbl = document.getElementById(TABLE_NAME);
             for (var i=0; i<tbl.tBodies[0].rows.length; i++) {
                 if (tbl.tBodies[0].rows[i].myRow && tbl.tBodies[0].rows[i].myRow.three.getAttribute('type') == 'checkbox' && tbl.tBodies[0].rows[i].myRow.three.checked) {
                     checkedObjArray[cCount] = tbl.tBodies[0].rows[i];
                     cCount++;
                 }
             }
             if (checkedObjArray.length > 0) {
                 var rIndex = checkedObjArray[0].sectionRowIndex;
                 deleteRows(checkedObjArray);
                 reorderRows(tbl, rIndex);
             }
         }
    }
    
    // If there isn't an element with an onclick event in your row, then this function can't be used.
    function deleteCurrentRow(obj)
    {
         if (hasLoaded) {
             var delRow = obj.parentNode.parentNode;
             var tbl = delRow.parentNode.parentNode;
             var rIndex = delRow.sectionRowIndex;
             var rowArray = new Array(delRow);
             deleteRows(rowArray);
             reorderRows(tbl, rIndex);
         }
    }
    
    function reorderRows(tbl, startingIndex)
    {
         if (hasLoaded) {
             if (tbl.tBodies[0].rows[startingIndex]) {
                 var count = startingIndex + ROW_BASE;
                 for (var i=startingIndex; i<tbl.tBodies[0].rows.length; i++) {
                 
                     // CONFIG: next line is affected by myRowObject settings
                     tbl.tBodies[0].rows[i].myRow.one.data = count; // text
                     
                     // CONFIG: next line is affected by myRowObject settings
                     tbl.tBodies[0].rows[i].myRow.two.name = INPUT_NAME_PREFIX + count; // input text
                     
                     // CONFIG: next line is affected by myRowObject settings
                     var tempVal = tbl.tBodies[0].rows[i].myRow.two.value.split(' '); // for debug purposes
                     tbl.tBodies[0].rows[i].myRow.two.value = count + ' was' + tempVal[0]; // for debug purposes
                     
                     // CONFIG: next line is affected by myRowObject settings
                     tbl.tBodies[0].rows[i].myRow.four.value = count; // input radio
                     
                     // CONFIG: requires class named classy0 and classy1
                     tbl.tBodies[0].rows[i].className = 'classy' + (count % 2);
                     
                     count++;
                 }
             }
         }
    }
    
    function deleteRows(rowObjArray)
    {
         if (hasLoaded) {
             for (var i=0; i<rowObjArray.length; i++) {
                 var rIndex = rowObjArray[i].sectionRowIndex;
                 rowObjArray[i].parentNode.deleteRow(rIndex);
             }
         }
    }
    
    function openInNewWindow(frm)
    {
         // open a blank window
         var aWindow = window.open('', 'TableAddRow2NewWindow',
         'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
         
         // set the target to the blank window
         frm.target = 'TableAddRow2NewWindow';
         
         // submit
         frm.submit();
    }
    

     

    Can anyone help???

     

  11. I have gotten a little further with my code and have figure out how to set some options but it is not working properly. I can add as many rows as I want and choose options, but if I delete the first option, the rest of the options' values will display on the next page. If I don't delete the option, it will not display the results at all. Can anyone help me figure out what is wrong with my code? Here are the changes I made:

     

    var cell1 = row.insertCell(1);
             var txtInp = document.createElement('select');
             //txtInp.setAttribute('value', 'name');
             //first option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Animal Guardian");
                     theOption.appendChild(theText);
                     theOption.setAttribute('name', INPUT_NAME_PREFIX + iteration);
                     txtInp.setAttribute('value', iteration); // iteration included for debug purposes
                     txtInp.appendChild(theOption);
                     
             //second option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Combined Attacks");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Combined Attacks');
                     txtInp.appendChild(theOption);
                     
             //third option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Elemental Control");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Elemental Control');
                     txtInp.appendChild(theOption);
                     
             //fourth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Emotional Control");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Emotional Control');
                     txtInp.appendChild(theOption);
                     
             //fifth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Item Of Power");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','Item Of Power');
                     txtInp.appendChild(theOption);
                     
             //sixth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Knight Attack");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','index2');
                     txtInp.appendChild(theOption);
                     
             //seventh option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Rejuvenation");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','index2');
                     txtInp.appendChild(theOption);
                     
             //eighth option
                    var theOption=document.createElement("OPTION");
                     var theText=document.createTextNode("Scout Attack");
                     theOption.appendChild(theText);
                     theOption.setAttribute('value','index2');
                     txtInp.appendChild(theOption);
    
             //txtInp.setAttribute('size', '5');
             
             cell1.appendChild(txtInp, theOption);
    

     

  12. I have the following simple form with a button that is supposed to add what the user puts in the text box into the select list as an option. But, my function doesn't appear to be doing anything. When I put text into the input text box, nothing happens. Here is my code:

     

    <html>
    <head>
    <title>Untitled Document</title>
    <script type="text/javascript">
    function addMagazine() {
    if (document.forms[0].elements[31].value == "")
    	window.alert("You must enter a magazine name.");
    else {
    	var magazine = new Option();
    	magazine.text = document.forms[0].elements[31].value;
    	magazine.value = document.forms[0].elements[31].value;
    	nextItem = document.forms[0].magazines.length;
    	document.forms[0].magazines.options[nextItem] = magazine;
    	document.forms[0].elements[31].value = "";
    }
    }
    </script>
    </head>
    
    <body>
    <form action="FormProcessor.html" method="get">
    <p>Magazine
    <input type="text" size="68" /></p>
    <p><input type="button" value="Add Magazine" onclick="addMagazine();"  style="width: 120px" /></p>
    <p><select name="magazines" multiple="multiple" size="10" style="width: 500px">
    <option value="none">Enter the magazine you subscribe to</option>
    </select></p>
    </form>
    </body>
    </html>
    
    

     

    Can anyone see something I am doing wrong?

  13. Can anyone tell me why this script isn't working? The calcGroupDiscount function isn't working for some reason.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Central Valley Snowboarding</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="js_styles.css" type="text/css" />
    </head>
    <body>
    <h1>Central Valley Snowboarding</h1>
    <h2>Group Reservations</h2>
    <form action="FormProcessor.html" method="get" enctype="application/x-www-form-urlencoded">
    <h3>Snowboarding Date</h3>
    <p><input type="text" name="reservationDate" />
    <a href="" onclick="displayCalendar()">Select Date</a></p>
    <h3>Group Leader</h3>
    <table border="0">
    <tr valign="top">
    <td>Last Name<br />
        <input type="text" name="leaderLastName" size="50" /><br />
        First Name<br />
        <input type="text" name="leaderFirstName" size="50" /><br />
        Telephone<br />
        <input type="text" name="leaderTelephone" size="50" /><br />
        Address<br />
        <input type="text" name="leaderAddress" size="50" /><br />
        City, State, Zip<br />
        <input type="text" name="leaderCity" size="34"  />
        <input type="text" name="leaderState" size="2" maxlength="2" />
        <input type="text" name="leaderZip" size="5" maxlength="5" /></td>
    </tr></table>
    <script type="text/javascript">
    
    //get date
    var dateObject = new Date();
    var month = dateObject.getMonth();
    var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    var dateToday = monthArray[month] + " " + dateObject.getDate() + "," + dateObject.getFullYear();
    document.forms[0].reservationDate.value = dateToday;
    
    //calculate group discount
    function calcGroupDiscount(groupsize) {
    var dailyRate = 49;
    if (groupSize > 5 && groupSize < 10)
    	dailyRate = 49 / 1.1;
    else if (groupSize > 10 && groupSize < 25)
    	dailyRate = 49 / 1.2;
    else if (groupSize > 24)
    	dailyRate = 49 / 1.25;
    var groupRate = groupSize * dailyRate;
    document.forms[0].discount.value = groupRate.toFixed(2);
    }
    </script>
    <h3>Group Discounts</h3>
    <ul>
    <li>Daily Rate: $49</li>
    <li>5-10 snowboarders: 10% discount</li>
    <li>11-24 snowboarders: 20% discount</li>
    <li>25+ snowboarders: 25% discount</li>
    </ul>
    <p>How many snowboarders are in your group? <input type="text" size="5" value="0" onchange="calcGroupDiscount(this.value)">
    <br />
    Your group rate is: $<input type="text" name="discount" size="60" value="0" readonly="readonly" style="border: none" /></p>
    <p><input type="submit" value="Submit Group Reservation" /><input type="reset" value="Reset" /></p>
    </form>
    </body>
    </html>
    

  14. Can anyone help me with how to write the javascript that woul add a select list and options to the following table adding/deleting code?

     

    
    var INPUT_NAME_PREFIX = 'inputName'; // this is being set via script
    var RADIO_NAME = 'totallyrad'; // this is being set via script
    var TABLE_NAME = 'tblSample'; // this should be named in the HTML
    var ROW_BASE = 1; // first number (for display)
    var hasLoaded = false;
    
    window.onload=fillInRows;
    
    function fillInRows()
    {
    hasLoaded = true;
    addRowToTable();
    addRowToTable();
    }
    
    // CONFIG:
    // myRowObject is an object for storing information about the table rows
    function myRowObject(one, two, three, four)
    {
    this.one = one; // text object
    this.two = two; // input text object
    this.three = three; // input checkbox object
    this.four = four; // input radio object
    }
    
    /*
    * insertRowToTable
    * Insert and reorder
    */
    function insertRowToTable()
    {
    if (hasLoaded) {
    	var tbl = document.getElementById(TABLE_NAME);
    	var rowToInsertAt = tbl.tBodies[0].rows.length;
    	for (var i=0; i<tbl.tBodies[0].rows.length; i++) {
    		if (tbl.tBodies[0].rows[i].myRow && tbl.tBodies[0].rows[i].myRow.four.getAttribute('type') == 'radio' && tbl.tBodies[0].rows[i].myRow.four.checked) {
    			rowToInsertAt = i;
    			break;
    		}
    	}
    	addRowToTable(rowToInsertAt);
    	reorderRows(tbl, rowToInsertAt);
    }
    }
    
    /*
    * addRowToTable
    * Inserts at row 'num', or appends to the end if no arguments are passed in. Don't pass in empty strings.
    */
    function addRowToTable(num)
    {
    if (hasLoaded) {
    	var tbl = document.getElementById(TABLE_NAME);
    	var nextRow = tbl.tBodies[0].rows.length;
    	var iteration = nextRow + ROW_BASE;
    	if (num == null) { 
    		num = nextRow;
    	} else {
    		iteration = num + ROW_BASE;
    	}
    
    	// add the row
    	var row = tbl.tBodies[0].insertRow(num);
    
    	// CONFIG: requires classes named classy0 and classy1
    	row.className = 'classy' + (iteration % 2);
    
    	// CONFIG: This whole section can be configured
    
    	// cell 0 - text
    	var cell0 = row.insertCell(0);
    	var textNode = document.createTextNode(iteration);
    	cell0.appendChild(textNode);
    
    	// cell 1 - input text
    	var cell1 = row.insertCell(1);
    	var txtInp = document.createElement('input');
    	txtInp.setAttribute('type', 'text');
    	txtInp.setAttribute('name', INPUT_NAME_PREFIX + iteration);
    	txtInp.setAttribute('size', '40');
    	txtInp.setAttribute('value', iteration); // iteration included for debug purposes
    	cell1.appendChild(txtInp);
    
    	// cell 2 - input button
    	var cell2 = row.insertCell(2);
    	var btnEl = document.createElement('input');
    	btnEl.setAttribute('type', 'button');
    	btnEl.setAttribute('value', 'Delete');
    	btnEl.onclick = function () {deleteCurrentRow(this)};
    	cell2.appendChild(btnEl);
    
    	// cell 3 - input checkbox
    	var cell3 = row.insertCell(3);
    	var cbEl = document.createElement('input');
    	cbEl.setAttribute('type', 'checkbox');
    	cell3.appendChild(cbEl);
    
    	// cell 4 - input radio
    	var cell4 = row.insertCell(4);
    	var raEl;
    	try {
    		raEl = document.createElement('<input type="radio" name="' + RADIO_NAME + '" value="' + iteration + '">');
    		var failIfNotIE = raEl.name.length;
    	} catch(ex) {
    		raEl = document.createElement('input');
    		raEl.setAttribute('type', 'radio');
    		raEl.setAttribute('name', RADIO_NAME);
    		raEl.setAttribute('value', iteration);
    	}
    	cell4.appendChild(raEl);
    
    	// Pass in the elements you want to reference later
    	// Store the myRow object in each row
    	row.myRow = new myRowObject(textNode, txtInp, cbEl, raEl);
    }
    }
    
    // CONFIG: this entire function is affected by myRowObject settings
    // If there isn't a checkbox in your row, then this function can't be used.
    function deleteChecked()
    {
    if (hasLoaded) {
    	var checkedObjArray = new Array();
    	var cCount = 0;
    
    	var tbl = document.getElementById(TABLE_NAME);
    	for (var i=0; i<tbl.tBodies[0].rows.length; i++) {
    		if (tbl.tBodies[0].rows[i].myRow && tbl.tBodies[0].rows[i].myRow.three.getAttribute('type') == 'checkbox' && tbl.tBodies[0].rows[i].myRow.three.checked) {
    			checkedObjArray[cCount] = tbl.tBodies[0].rows[i];
    			cCount++;
    		}
    	}
    	if (checkedObjArray.length > 0) {
    		var rIndex = checkedObjArray[0].sectionRowIndex;
    		deleteRows(checkedObjArray);
    		reorderRows(tbl, rIndex);
    	}
    }
    }
    
    // If there isn't an element with an onclick event in your row, then this function can't be used.
    function deleteCurrentRow(obj)
    {
    if (hasLoaded) {
    	var delRow = obj.parentNode.parentNode;
    	var tbl = delRow.parentNode.parentNode;
    	var rIndex = delRow.sectionRowIndex;
    	var rowArray = new Array(delRow);
    	deleteRows(rowArray);
    	reorderRows(tbl, rIndex);
    }
    }
    
    function reorderRows(tbl, startingIndex)
    {
    if (hasLoaded) {
    	if (tbl.tBodies[0].rows[startingIndex]) {
    		var count = startingIndex + ROW_BASE;
    		for (var i=startingIndex; i<tbl.tBodies[0].rows.length; i++) {
    
    			// CONFIG: next line is affected by myRowObject settings
    			tbl.tBodies[0].rows[i].myRow.one.data = count; // text
    
    			// CONFIG: next line is affected by myRowObject settings
    			tbl.tBodies[0].rows[i].myRow.two.name = INPUT_NAME_PREFIX + count; // input text
    
    			// CONFIG: next line is affected by myRowObject settings
    			var tempVal = tbl.tBodies[0].rows[i].myRow.two.value.split(' '); // for debug purposes
    			tbl.tBodies[0].rows[i].myRow.two.value = count + ' was' + tempVal[0]; // for debug purposes
    
    			// CONFIG: next line is affected by myRowObject settings
    			tbl.tBodies[0].rows[i].myRow.four.value = count; // input radio
    
    			// CONFIG: requires class named classy0 and classy1
    			tbl.tBodies[0].rows[i].className = 'classy' + (count % 2);
    
    			count++;
    		}
    	}
    }
    }
    
    function deleteRows(rowObjArray)
    {
    if (hasLoaded) {
    	for (var i=0; i<rowObjArray.length; i++) {
    		var rIndex = rowObjArray[i].sectionRowIndex;
    		rowObjArray[i].parentNode.deleteRow(rIndex);
    	}
    }
    }
    
    function openInNewWindow(frm)
    {
    // open a blank window
    var aWindow = window.open('', 'TableAddRow2NewWindow',
    'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
    
    // set the target to the blank window
    frm.target = 'TableAddRow2NewWindow';
    
    // submit
    frm.submit();
    }
    
    

  15. I found a way to do it:

     

    <?php
    
    session_start();
    if(!isset($_SESSION['loggedIn'])) {
    header("Location: login.php");
    }
    
    function yearOfBirth ($day, $month, $age)
    {
        $now = strtotime('1992-03-23');
    
        $yob = date('Y', $now) - $age;
        
        if (date('md', $now) < sprintf('%02d%02d', $month, $day)) $yob--;
        
        return $yob;
    }
    
    $year =  yearOfBirth($_POST['birth_date'], $_POST['birth_month'], $_POST['age']);
    
    //store our posted values in the session variables
    $_SESSION['identity'] = $_POST['identity'];
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['element_of_influence'] = $_POST['element_of_influence'];
    $_SESSION['age'] = $_POST['age'];
    $_SESSION['birth_month'] = $_POST['birth_month'];
    $_SESSION['birth_date'] = $_POST['birth_date'];
    $_SESSION['birth_year'] = $year;
    $_SESSION['blood_type'] = $_POST['blood_type'];
    $_SESSION['hobbies'] = $_POST['hobbies'];
    $_SESSION['favorite_color'] = $_POST['favorite_color'];
    $_SESSION['favorite_gemstone'] = $_POST['favorite_gemstone'];
    $_SESSION['favorite_food'] = $_POST['favorite_food'];
    $_SESSION['least_favorite_food'] = $_POST['least_favorite_food'];
    $_SESSION['favorite_school_subject'] = $_POST['favorite_school_subject'];
    $_SESSION['least_favorite_school_subject'] = $_POST['least_favorite_school_subject'];
    $_SESSION['strengths'] = $_POST['strengths'];
    $_SESSION['weaknesses'] = $_POST['weaknesses'];
    $_SESSION['goal'] = $_POST['goal'];
    $_SESSION['mission'] = $_POST['mission'];
    $_SESSION['biography'] = $_POST['biography'];
    $_SESSION['height_feet'] = $_POST['height_feet'];
    $_SESSION['height_inches'] = $_POST['height_inches'];
    
    //Access Tracking Snippet
    
    //set up static variables
    $page_title = "stats.php";
    $user_agent = getenv("HTTP_USER_AGENT");
    $date_accessed = date("Y-m-d");
    
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
    or die(mysql_error());
    $db = mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    //create and issue query
    $sql = "insert into access_tracker values
    ('', '$page_title', '$user_agent', '$date_accessed')";
    mysql_query($sql,$conn);
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Sailor Moon RPG - Character Creation Form | Stats</title>
    <style type="text/css" media="screen">
    /*<![CDATA[*/
    @import url(global.css); 
    /*]]>*/
    </style>
    <!-- Script for calculating Derived Values -->
    <script language="javascript">
    
    function filledOut(){
    if (document.forms[0].bodyv.value != "" && document.forms[0].mind.value != "" && document.forms[0].soul.value != ""){
    	acv();
    	dcv();
    	healthv();
    	energyv();
    }
    }
    
    function healthv()
    {
    var first,sec,third,res1;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res1=(first+third)*5;
    //show the result in the result textbox
    document.forms[0].health.value=res1;
    }
    
    function energyv()
    {
    var sec,third,res2;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res2=(sec+third)*5;
    //show the result in the result textbox
    document.forms[0].energy.value=res2;
    }
    
    function acv()
    {
    var first,sec,third,res3;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res3=Math.floor((first+sec+third)/3);
    //show the result in the result textbox
    document.forms[0].acv1.value=res3;
    }
    
    function dcv()
    {
    var first,sec,third,res4;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res4=Math.floor((first+sec+third)/3 -2);
    //show the result in the result textbox
    document.forms[0].dcv1.value=res4;
    }
    </script>
    <!-- End Derived Values Script -->
    </head>
    <body>
    <!-- HEADER -->
    <h1 class="logo">Sailor Moon RPG</h1>
    <!-- /HEADER -->
    <?php include("topnav.php"); ?>
    <div id="main">
    <?php include("includes/log.php"); ?>
    <?php include("mainnav.php"); ?>
    <h1>Step 2: Character Outline - Creation</h1>
    <h2>Stats And Derived Values</h2>
    <form name="stats" method="post" action="insert_scout.php">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><div align="left"><strong>Body:</strong></div></td>
    <td><input name="bodyv" type="text" id="bodyv" size="5" maxlength="2" onBlur="filledOut()" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Mind:</strong></div></td>
    <td><input name="mind" type="text" id="mind" size="5" maxlength="2" onBlur="filledOut()" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Soul:</strong></div></td>
    <td><input name="soul" type="text" id="soul" size="5" maxlength="2" onBlur="filledOut()" /></td>
    </tr>
    <tr>
    <td></td>
    <td> </td>
    </tr>
    <tr>
    <td><div align="left"><strong>Health Points:</strong></div></td>
    <td><input name="health" type="text" id="health"readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Energy Points:</strong></div></td>
    <td><input name="energy" type="text" id="energy" readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Attack Combat Value:</strong></div></td>
    <td><input name="acv1" type="text" id="acv1" readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Defense Combat Value:</strong></div></td>
    <td><input name="dcv1" type="text" id="dcv1" readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td> </td>
    <td>
    <input name="total_cp" type="hidden" id="total_cp" value="10" /></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><input name="calcstats" type="submit" id="submit" value="Next" >
    <input type="reset" value="Reset" /></div></td>
    </tr>
    </table>
    </form>
    </div>
    <?php include("bottomnav.php"); ?>
    <!-- FOOTER -->
    <div id="footer_wrapper">
    <div id="footer">
    <p>Sailor Moon and all characters are<br>
    trademarks of Naoko Takeuchi.</p>
    <p>Copyright © 2009 Liz Kula. All rights reserved.<br>
    A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
    <div id="foot-nav"><!-- <ul>
    <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
    <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
    </ul> --></div>
    </div>
    </div>
    <!-- /FOOTER -->
    </body>
    </html>
    
    

  16. I added another function that checks if the fields have values before performing the other functions and now it works. Here is what I have:

     

    function filledOut(){
    if (document.forms[0].bodyv.value != "" && document.forms[0].mind.value != "" && document.forms[0].soul.value != ""){
    	acv();
    	dcv();
    	healthv();
    	energyv();
    }
    }
    

     

    I just ran this function on each of the fields, and in turn the other functions get run if the appropriate fields are filled in. Here's the full code for reference:

     

    <?php
    
    session_start();
    if(!isset($_SESSION['loggedIn'])) {
    header("Location: login.php");
    }
    
    function yearOfBirth ($day, $month, $age)
    {
        $now = strtotime('1992-03-23');
    
        $yob = date('Y', $now) - $age;
        
        if (date('md', $now) < sprintf('%02d%02d', $month, $day)) $yob--;
        
        return $yob;
    }
    
    $year =  yearOfBirth($_POST['birth_date'], $_POST['birth_month'], $_POST['age']);
    
    //store our posted values in the session variables
    $_SESSION['identity'] = $_POST['identity'];
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['element_of_influence'] = $_POST['element_of_influence'];
    $_SESSION['age'] = $_POST['age'];
    $_SESSION['birth_month'] = $_POST['birth_month'];
    $_SESSION['birth_date'] = $_POST['birth_date'];
    $_SESSION['birth_year'] = $year;
    $_SESSION['blood_type'] = $_POST['blood_type'];
    $_SESSION['hobbies'] = $_POST['hobbies'];
    $_SESSION['favorite_color'] = $_POST['favorite_color'];
    $_SESSION['favorite_gemstone'] = $_POST['favorite_gemstone'];
    $_SESSION['favorite_food'] = $_POST['favorite_food'];
    $_SESSION['least_favorite_food'] = $_POST['least_favorite_food'];
    $_SESSION['favorite_school_subject'] = $_POST['favorite_school_subject'];
    $_SESSION['least_favorite_school_subject'] = $_POST['least_favorite_school_subject'];
    $_SESSION['strengths'] = $_POST['strengths'];
    $_SESSION['weaknesses'] = $_POST['weaknesses'];
    $_SESSION['goal'] = $_POST['goal'];
    $_SESSION['mission'] = $_POST['mission'];
    $_SESSION['biography'] = $_POST['biography'];
    $_SESSION['height_feet'] = $_POST['height_feet'];
    $_SESSION['height_inches'] = $_POST['height_inches'];
    
    //Access Tracking Snippet
    
    //set up static variables
    $page_title = "stats.php";
    $user_agent = getenv("HTTP_USER_AGENT");
    $date_accessed = date("Y-m-d");
    
    //connect to server and select database
    $conn = mysql_connect("localhost", "root", "")
    or die(mysql_error());
    $db = mysql_select_db("smrpg", $conn) or die(mysql_error());
    
    //create and issue query
    $sql = "insert into access_tracker values
    ('', '$page_title', '$user_agent', '$date_accessed')";
    mysql_query($sql,$conn);
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Sailor Moon RPG - Character Creation Form | Stats</title>
    <style type="text/css" media="screen">
    /*<![CDATA[*/
    @import url(global.css); 
    /*]]>*/
    </style>
    <!-- Script for calculating Derived Values -->
    <script language="javascript">
    
    function filledOut(){
    if (document.forms[0].bodyv.value != "" && document.forms[0].mind.value != "" && document.forms[0].soul.value != ""){
    	acv();
    	dcv();
    	healthv();
    	energyv();
    }
    }
    
    function healthv()
    {
    var first,sec,third,res1;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res1=(first+third)*5;
    //show the result in the result textbox
    document.forms[0].health.value=res1;
    }
    
    function energyv()
    {
    var sec,third,res2;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res2=(sec+third)*5;
    //show the result in the result textbox
    document.forms[0].energy.value=res2;
    }
    
    function acv()
    {
    var first,sec,third,res3;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res3=Math.floor((first+sec+third)/3);
    //show the result in the result textbox
    document.forms[0].acv1.value=res3;
    }
    
    function dcv()
    {
    var first,sec,third,res4;
    //Take the value of first textbox and convert it to float
    first=parseFloat(document.forms[0].bodyv.value);
    //Take the value of second textbox and convert it to float
    sec=parseFloat(document.forms[0].mind.value);
    //third
    third=parseFloat(document.forms[0].soul.value);
    res4=Math.floor((first+sec+third)/3 -2);
    //show the result in the result textbox
    document.forms[0].dcv1.value=res4;
    }
    </script>
    <!-- End Derived Values Script -->
    </head>
    <body>
    <!-- HEADER -->
    <h1 class="logo">Sailor Moon RPG</h1>
    <!-- /HEADER -->
    <?php include("topnav.php"); ?>
    <div id="main">
    <?php include("includes/log.php"); ?>
    <?php include("mainnav.php"); ?>
    <h1>Step 2: Character Outline - Creation</h1>
    <h2>Stats And Derived Values</h2>
    <form name="stats" method="post" action="insert_scout.php">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><div align="left"><strong>Body:</strong></div></td>
    <td><input name="bodyv" type="text" id="bodyv" size="5" maxlength="2" onBlur="filledOut()" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Mind:</strong></div></td>
    <td><input name="mind" type="text" id="mind" size="5" maxlength="2" onBlur="filledOut()" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Soul:</strong></div></td>
    <td><input name="soul" type="text" id="soul" size="5" maxlength="2" onBlur="filledOut()" /></td>
    </tr>
    <tr>
    <td></td>
    <td> </td>
    </tr>
    <tr>
    <td><div align="left"><strong>Health Points:</strong></div></td>
    <td><input name="health" type="text" id="health"readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Energy Points:</strong></div></td>
    <td><input name="energy" type="text" id="energy" readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Attack Combat Value:</strong></div></td>
    <td><input name="acv1" type="text" id="acv1" readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td><div align="left"><strong>Defense Combat Value:</strong></div></td>
    <td><input name="dcv1" type="text" id="dcv1" readonly="readonly" size="5" maxlength="2" /></td>
    </tr>
    <tr>
    <td> </td>
    <td>
    <input name="total_cp" type="hidden" id="total_cp" value="10" /></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><input name="calcstats" type="submit" id="submit" value="Next" >
    <input type="reset" value="Reset" /></div></td>
    </tr>
    </table>
    </form>
    </div>
    <?php include("bottomnav.php"); ?>
    <!-- FOOTER -->
    <div id="footer_wrapper">
    <div id="footer">
    <p>Sailor Moon and all characters are<br>
    trademarks of Naoko Takeuchi.</p>
    <p>Copyright © 2009 Liz Kula. All rights reserved.<br>
    A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
    <div id="foot-nav"><!-- <ul>
    <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
    <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
    </ul> --></div>
    </div>
    </div>
    <!-- /FOOTER -->
    </body>
    </html>
    

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.