Dragonfly CMS v9 ⇒ Gamers Modules & Blocks :: Archives ⇒ Help with City of Heroes Roster Module :: Archived ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Index Modules & Blocks Gamers Modules & Blocks ⇒ Archives

Archived ⇒ Help with City of Heroes Roster Module


Hi I'm attempting to create a City of Heroes roster/chracter creation form module for my SG site. I've got the form created and in it's basic format will post info to the database. What I wanted to do was have the form get the user_id # and post this in the form as well, and made it key. So characters can be listed by user_id. I'm having trouble understanding what I need to do. Here is the code as it stands now:
<?php if (!defined('CPG_NUKE')) { exit; } $theme="wsg_navy_steam"; include("header.php"); if (isset($_SESSION['user_id'])) if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO characters (user_id, charactername, image, secretid, `level`, archetype, origin, `primary`, secondary, pool, epic, background, main) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['$_SESSION[user_id]'], "int"), GetSQLValueString($_POST['charactername'], "text"), GetSQLValueString($_POST['image'], "text"), GetSQLValueString($_POST['secretid'], "text"), GetSQLValueString($_POST['level'], "int"), GetSQLValueString($_POST['archetype'], "text"), GetSQLValueString($_POST['origin'], "text"), GetSQLValueString($_POST['primary'], "text"), GetSQLValueString($_POST['secondary'], "text"), GetSQLValueString($_POST['pool'], "text"), GetSQLValueString($_POST['epic'], "text"), GetSQLValueString($_POST['background'], "text"), GetSQLValueString($_POST['main'], "text")); mysql_select_db($database_Minutemen, $Minutemen); $Result1 = mysql_query($insertSQL, $Minutemen) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_Minutemen, $Minutemen); $query_characters = "SELECT * FROM characters"; $characters = mysql_query($query_characters, $Minutemen) or die(mysql_error()); $row_characters = mysql_fetch_assoc($characters); $totalRows_characters = mysql_num_rows($characters); ?><!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1"> <table align="center"> <tr valign="baseline"> <td nowrap align="left">Hero ID:</td> <td><input name="charactername" type="text" value="" size="32" maxlength="32"></td> </tr> <tr valign="baseline"> <td nowrap align="left">URL for Image File:</td> <td><input name="image" type="text" size="32" maxlength="200" value="http://"/> <label for="file"></label></td> </tr> <tr valign="baseline"> <td nowrap align="left">Secret ID:</td> <td><input name="secretid" type="text" value="" size="32" maxlength="32"></td> </tr> <tr valign="baseline"> <td nowrap align="left">Security Level:</td> <td><input name="level" type="text" value="" size="2" maxlength="2"></td> </tr> <tr valign="baseline"> <td nowrap align="left">Archetype:</td> <td><select name="archetype"> <option value="Select One" <?php if (!(strcmp("None", ""))) {echo "SELECTED";} ?>>-Select One-</option> <option value="Blaster" <?php if (!(strcmp("Blaster", ""))) {echo "SELECTED";} ?>>Blaster</option> <option value="Controller" <?php if (!(strcmp("Controller", ""))) {echo "SELECTED";} ?>>Controller</option> <option value="Defender" <?php if (!(strcmp("Defender", ""))) {echo "SELECTED";} ?>>Defender</option> <option value="Peacebringer" <?php if (!(strcmp("Peacebringer", ""))) {echo "SELECTED";} ?>>Peacebringer</option> <option value="Scrapper" <?php if (!(strcmp("Scrapper", ""))) {echo "SELECTED";} ?>>Scrapper</option> <option value="Tanker" <?php if (!(strcmp("Tanker", ""))) {echo "SELECTED";} ?>>Tanker</option> <option value="Warshade" <?php if (!(strcmp("Warshade", ""))) {echo "SELECTED";} ?>>Warshade</option> </select> </td> </tr> <tr valign="baseline"> <td nowrap align="left">Origin:</td> <td><select name="origin"> <option value="Select One" <?php if (!(strcmp("None", ""))) {echo "SELECTED";} ?>>-Select One-</option> <option value="Magic" <?php if (!(strcmp("Magic", ""))) {echo "SELECTED";} ?>>Magic</option> <option value="Mutant" <?php if (!(strcmp("Mutant", ""))) {echo "SELECTED";} ?>>Mutant</option> <option value="Natural" <?php if (!(strcmp("Natural", ""))) {echo "SELECTED";} ?>>Natural</option> <option value="Science" <?php if (!(strcmp("Science", ""))) {echo "SELECTED";} ?>>Science</option> <option value="Technology" <?php if (!(strcmp("Technology", ""))) {echo "SELECTED";} ?>>Technology</option> </select> </td> </tr> <tr valign="baseline"> <td nowrap align="left">Primary Power Set:</td> <td><select name="primary"> <option value="Select One" <?php if (!(strcmp("None", ""))) {echo "SELECTED";} ?>>-Select One-</option> <option value="Archery" <?php if (!(strcmp("Archery", ""))) {echo "SELECTED";} ?>>Archery</option> <option value="Assault Rifle" <?php if (!(strcmp("Assault Rifle", ""))) {echo "SELECTED";} ?>>Assault Rifle</option> <option value="Broadsword" <?php if (!(strcmp("Broadsword", ""))) {echo "SELECTED";} ?>>Broadsword</option> <option value="Claws" <?php if (!(strcmp("Claws", ""))) {echo "SELECTED";} ?>>Claws</option> <option value="Dark Melee" <?php if (!(strcmp("Dark Melee", ""))) {echo "SELECTED";} ?>>Dark Melee</option> <option value="Dark Miasma" <?php if (!(strcmp("Dark Miasma", ""))) {echo "SELECTED";} ?>>Dark Miasma</option> <option value="Earth Control" <?php if (!(strcmp("Earth Control", ""))) {echo "SELECTED";} ?>>Earth Control</option> <option value="Electrical Blast" <?php if (!(strcmp("Electrical Blast", ""))) {echo "SELECTED";} ?>>Electrical Blast</option> <option value="Empathy" <?php if (!(strcmp("Empathy", ""))) {echo "SELECTED";} ?>>Empathy</option> <option value="Energy Blast" <?php if (!(strcmp("Energy Blast", ""))) {echo "SELECTED";} ?>>Energy Blast</option> <option value="Fiery Aura" <?php if (!(strcmp("Fiery Aura", ""))) {echo "SELECTED";} ?>>Fiery Aura</option> <option value="Fire Blast" <?php if (!(strcmp("Fire Blast", ""))) {echo "SELECTED";} ?>>Fire Blast</option> <option value="Fire Control" <?php if (!(strcmp("Fire Control", ""))) {echo "SELECTED";} ?>>Fire Control</option> <option value="Force Field" <?php if (!(strcmp("Force Field", ""))) {echo "SELECTED";} ?>>Force Field</option> <option value="Gravity Control" <?php if (!(strcmp("Gravity Control", ""))) {echo "SELECTED";} ?>>Gravity Control</option> <option value="Ice Armor" <?php if (!(strcmp("Ice Armor", ""))) {echo "SELECTED";} ?>>Ice Armor</option> <option value="Ice Blast" <?php if (!(strcmp("Ice Blast", ""))) {echo "SELECTED";} ?>>Ice Blast</option> <option value="Ice Control" <?php if (!(strcmp("Ice Control", ""))) {echo "SELECTED";} ?>>Ice Control</option> <option value="Illusion Control" <?php if (!(strcmp("Illusion Control", ""))) {echo "SELECTED";} ?>>Illusion Control</option> <option value="Invulnerability" <?php if (!(strcmp("Invulnerability", ""))) {echo "SELECTED";} ?>>Invulnerability</option> <option value="Katana" <?php if (!(strcmp("Katana", ""))) {echo "SELECTED";} ?>>Katana</option> <option value="Kinetics" <?php if (!(strcmp("Kinetics", ""))) {echo "SELECTED";} ?>>Kinetics</option> <option value="Luminous Blast" <?php if (!(strcmp("Luminous Blast", ""))) {echo "SELECTED";} ?>>Luminous Blast</option> <option value="Martial Arts" <?php if (!(strcmp("Martial Arts", ""))) {echo "SELECTED";} ?>>Martial Arts</option> <option value="Mind Control" <?php if (!(strcmp("Mind Control", ""))) {echo "SELECTED";} ?>>Mind Control</option> <option value="Radiation Emission" <?php if (!(strcmp("Radiation Emission", ""))) {echo "SELECTED";} ?>>Radiation Emission</option> <option value="Sonic Attack" <?php if (!(strcmp("Sonic Attack", ""))) {echo "SELECTED";} ?>>Sonic Attack</option> <option value="Sonic Resonance" <?php if (!(strcmp("Sonic Resonance", ""))) {echo "SELECTED";} ?>>Sonic Resonance</option> <option value="Spines" <?php if (!(strcmp("Spines", ""))) {echo "SELECTED";} ?>>Spines</option> <option value="Stone Armor" <?php if (!(strcmp("Stone Armor", ""))) {echo "SELECTED";} ?>>Stone Armor</option> <option value="Storm Summoning" <?php if (!(strcmp("Storm Summoning", ""))) {echo "SELECTED";} ?>>Storm Summoning</option> <option value="Trick Arrow" <?php if (!(strcmp("Trick Arrow", ""))) {echo "SELECTED";} ?>>Trick Arrow</option> <option value="Umbral Blast" <?php if (!(strcmp("Umbral Blast", ""))) {echo "SELECTED";} ?>>Umbral Blast</option> </select> </td> </tr> <tr valign="baseline"> <td nowrap align="left">Secondary Power Set:</td> <td><select name="secondary"> <option value="Select One" <?php if (!(strcmp("None", ""))) {echo "SELECTED";} ?>>-Select One-</option> <option value="Archery" <?php if (!(strcmp("Archery", ""))) {echo "SELECTED";} ?>>Archery</option> <option value="Battleaxe" <?php if (!(strcmp("Battleaxe", ""))) {echo "SELECTED";} ?>>Battleaxe</option> <option value="Dark Armor" <?php if (!(strcmp("Dark Armor", ""))) {echo "SELECTED";} ?>>Dark Armor</option> <option value="Dark Blast" <?php if (!(strcmp("Dark Blast", ""))) {echo "SELECTED";} ?>>Dark Blast</option> <option value="Devices" <?php if (!(strcmp("Devices", ""))) {echo "SELECTED";} ?>>Devices</option> <option value="Electrical Blast" <?php if (!(strcmp("Electrical Blast", ""))) {echo "SELECTED";} ?>>Electrical Blast</option> <option value="Electricity Manipulation" <?php if (!(strcmp("Electricity Manipulation", ""))) {echo "SELECTED";} ?>>Electricity Manipulation</option> <option value="Empathy" <?php if (!(strcmp("Empathy", ""))) {echo "SELECTED";} ?>>Empathy</option> <option value="Energy Blast" <?php if (!(strcmp("Energy Blast", ""))) {echo "SELECTED";} ?>>Energy Blast</option> <option value="Energy Manipulation" <?php if (!(strcmp("Energy Manipulation", ""))) {echo "SELECTED";} ?>>Energy Manipulation</option> <option value="Energy Melee" <?php if (!(strcmp("Energy Melee", ""))) {echo "SELECTED";} ?>>Energy Melee</option> <option value="Fire Manipulation" <?php if (!(strcmp("Fire Manipulation", ""))) {echo "SELECTED";} ?>>Fire Manipulation</option> <option value="Fiery Melee" <?php if (!(strcmp("Fiery Melee", ""))) {echo "SELECTED";} ?>>Fiery Melee</option> <option value="Force Field" <?php if (!(strcmp("Force Field", ""))) {echo "SELECTED";} ?>>Force Field</option> <option value="Ice Manipulation" <?php if (!(strcmp("Ice Manipulation", ""))) {echo "SELECTED";} ?>>Ice Manipulation</option> <option value="Ice Melee" <?php if (!(strcmp("Ice Melee", ""))) {echo "SELECTED";} ?>>Ice Melee</option> <option value="Invulnerability" <?php if (!(strcmp("Invulnerability", ""))) {echo "SELECTED";} ?>>Invulnerability</option> <option value="Kinetics" <?php if (!(strcmp("Kinetics", ""))) {echo "SELECTED";} ?>>Kinetics</option> <option value="Luminous Aura" <?php if (!(strcmp("Luminous Aura", ""))) {echo "SELECTED";} ?>>Luminous Aura</option> <option value="Psychic Blast" <?php if (!(strcmp("Psychic Blast", ""))) {echo "SELECTED";} ?>>Psychic Blast</option> <option value="Radiation Blast" <?php if (!(strcmp("Radiation Blast", ""))) {echo "SELECTED";} ?>>Radiation Blast</option> <option value="Radiation Emission" <?php if (!(strcmp("Radiation Emission", ""))) {echo "SELECTED";} ?>>Radiation Emission</option> <option value="Regeneration" <?php if (!(strcmp("Regeneration", ""))) {echo "SELECTED";} ?>>Regeneration</option> <option value="Sonic Attack" <?php if (!(strcmp("Sonic Attack", ""))) {echo "SELECTED";} ?>>Sonic Attack</option> <option value="Sonic Resonance" <?php if (!(strcmp("Sonic Resonance", ""))) {echo "SELECTED";} ?>>Sonic Resonance</option> <option value="Stone Melee" <?php if (!(strcmp("Stone Melee", ""))) {echo "SELECTED";} ?>>Stone Melee</option> <option value="Storm Summoning" <?php if (!(strcmp("Storm Summoning", ""))) {echo "SELECTED";} ?>>Storm Summoning</option> <option value="Super Reflexes" <?php if (!(strcmp("Super Reflexes", ""))) {echo "SELECTED";} ?>>Super Reflexes</option> <option value="Super Strength" <?php if (!(strcmp("Super Strength", ""))) {echo "SELECTED";} ?>>Super Strength</option> <option value="Trick Arrow" <?php if (!(strcmp("Trick Arrow", ""))) {echo "SELECTED";} ?>>Trick Arrow</option> <option value="Umbral Aura" <?php if (!(strcmp("Umbral Aura", ""))) {echo "SELECTED";} ?>>Umbral Aura</option> <option value="War Mace" <?php if (!(strcmp("War Mace", ""))) {echo "SELECTED";} ?>>War Mace</option> </select> </td> </tr> <tr valign="baseline"> <td align="left" valign="top" nowrap><p>Power Pools </p> <p>(hold CTRL+LClick to select more than one):</p></td> <td><select name="pool" size="10" multiple="multiple"> <option value="" >n/a</option> <option value="Concealment" <?php if (!(strcmp("Concealment", ""))) {echo "SELECTED";} ?>>Concealment</option> <option value="Fighting" <?php if (!(strcmp("Fighting", ""))) {echo "SELECTED";} ?>>Fighting</option> <option value="Fitness" <?php if (!(strcmp("Fitness", ""))) {echo "SELECTED";} ?>>Fitness</option> <option value="Flight" <?php if (!(strcmp("Flight", ""))) {echo "SELECTED";} ?>>Flight</option> <option value="Leadership" <?php if (!(strcmp("Leadership", ""))) {echo "SELECTED";} ?>>Leadership</option> <option value="Leaping" <?php if (!(strcmp("Leaping", ""))) {echo "SELECTED";} ?>>Leaping</option> <option value="Medicine" <?php if (!(strcmp("Medicine", ""))) {echo "SELECTED";} ?>>Medicine</option> <option value="Presence" <?php if (!(strcmp("Presence", ""))) {echo "SELECTED";} ?>>Presence</option> <option value="Speed" <?php if (!(strcmp("Speed", ""))) {echo "SELECTED";} ?>>Speed</option> <option value="Teleportation" <?php if (!(strcmp("Teleportation", ""))) {echo "SELECTED";} ?>>Teleportation</option> </select> </td> </tr> <tr valign="baseline"> <td align="left" valign="top" nowrap>Epic Power Pool:</td> <td><select name="epic"> <option value="" >n/a</option> <option value="Arctic Mastery" <?php if (!(strcmp("Arctic Mastery", ""))) {echo "SELECTED";} ?>>Arctic Mastery</option> <option value="Body Mastery" <?php if (!(strcmp("Body Mastery", ""))) {echo "SELECTED";} ?>>Body Mastery</option> <option value="Cold Mastery" <?php if (!(strcmp("Cold Mastery", ""))) {echo "SELECTED";} ?>>Cold Mastery</option> <option value="Dark Mastery" <?php if (!(strcmp("Dark Mastery", ""))) {echo "SELECTED";} ?>>Dark Mastery</option> <option value="Darkness Mastery" <?php if (!(strcmp("Darkness Mastery", ""))) {echo "SELECTED";} ?>>Darkness Mastery</option> <option value="Earth Mastery" <?php if (!(strcmp("Earth Mastery", ""))) {echo "SELECTED";} ?>>Earth Mastery</option> <option value="Electric Mastery" <?php if (!(strcmp("Electric Mastery", ""))) {echo "SELECTED";} ?>>Electric Mastery</option> <option value="Energy Mastery" <?php if (!(strcmp("Energy Mastery", ""))) {echo "SELECTED";} ?>>Energy Mastery</option> <option value="Fire Mastery" <?php if (!(strcmp("Fire Mastery", ""))) {echo "SELECTED";} ?>>Fire Mastery</option> <option value="Flame Mastery" <?php if (!(strcmp("Flame Mastery", ""))) {echo "SELECTED";} ?>>Flame Mastery</option> <option value="Force Mastery" <?php if (!(strcmp("Force Mastery", ""))) {echo "SELECTED";} ?>>Force Mastery</option> <option value="Ice Mastery" <?php if (!(strcmp("Ice Mastery", ""))) {echo "SELECTED";} ?>>Ice Mastery</option> <option value="Munitions Mastery" <?php if (!(strcmp("Munitions Mastery", ""))) {echo "SELECTED";} ?>>Munitions Mastery</option> <option value="Power Mastery" <?php if (!(strcmp("Power Mastery", ""))) {echo "SELECTED";} ?>>Power Mastery</option> <option value="Primal Forces" <?php if (!(strcmp("Primal Forces", ""))) {echo "SELECTED";} ?>>Primal Forces</option> <option value="Psionic Mastery" <?php if (!(strcmp("Psionic Mastery", ""))) {echo "SELECTED";} ?>>Psionic Mastery</option> <option value="Psychic Mastery" <?php if (!(strcmp("Psychic Mastery", ""))) {echo "SELECTED";} ?>>Psychic Mastery</option> <option value="Pyre Mastery" <?php if (!(strcmp("Pyre Mastery", ""))) {echo "SELECTED";} ?>>Pyre Mastery</option> <option value="Stone Mastery" <?php if (!(strcmp("Stone Mastery", ""))) {echo "SELECTED";} ?>>Stone Mastery</option> <option value="Weapon Mastery" <?php if (!(strcmp("Weapon Mastery", ""))) {echo "SELECTED";} ?>>Weapon Mastery</option> </select> </td> </tr> <tr valign="baseline"> <td align="left" valign="middle" nowrap>Background:</td> <td><textarea name="background" cols="50" rows="10" wrap="virtual"></textarea></td> </tr> <tr valign="baseline"> <td nowrap align="left">This is my: :</td> <td valign="baseline"><table> <tr> <td width="90"><input type="radio" name="main" value="Main" > Main:</td> <td width="91"><input type="radio" name="main" value="ALT" /> ALT:</td> </tr> </table></td> </tr> <tr valign="baseline"> <td nowrap align="left"><input type="reset" name="Reset" value="Reset" /></td> <td><input type="submit" value="Submit Hero"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form> <p> </p> </body> </html> <?php mysql_free_result($characters); include("footer.php"); ?>
I got the if (isset($_SESSION['user_id'])) from looking at some publsihed modules tha had a similar funtcion going on, but when I rant he script as is, I got a parsing error on line 43.

I tried also using a database query, but the form was posted twice-withthe submit button hit once. Once with the user_id added but the rest of the form was blank, and the rest with 0 for the user_id and the fields filled in.

Im pretty new to PhP (duh!) and I guess I don't understand what needs to be done here. Any help and suggestions would be greatly appreciated.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Managed-LLinux/1.3.29/4.0.27/5.2.0/9.1.1


ummm hello? Anyone?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Managed-LLinux/1.3.29/4.0.27/5.2.0/9.1.1


As I understand it, you are wanting the user_id of the member currently viewing the form. If so use the variable $userinfo['user_id'] to grab the persons user_id. Thats the variable I use for member info.

{SIG REMOVED - PLEASE REDUCE TO REGULATION SIZE}

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/1.3.33/4.1.13-standard/4.3.11/9.0.6.1


mikalquartz wrote
As I understand it, you are wanting the user_id of the member currently viewing the form. If so use the variable $userinfo['user_id'] to grab the persons user_id. Thats the variable I use for member info.


Close....I want the user_id of the person viewing the form to get posted in the database along with the other information from the selected fields.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Managed-LLinux/1.3.29/4.0.27/5.2.0/9.1.1


Hey I got i figured out. now I'm a third of the way done. Dancing

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Managed-LLinux/1.3.29/4.0.27/5.2.0/9.1.1

All times are UTC