Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
getting undefined error message and $_POST array not filling
Old 07-23-2010, 11:08 AM getting undefined error message and $_POST array not filling
Webmaster Talker

Posts: 611
Trades: 0
Hi I am getting error messages like this. A lot of them.

Code:
Notice:  Undefined index: strength in C:\wamp\www\dragon_game\dragon_game\ability_points.php on line 45

Notice:  Undefined index: wisdom in C:\wamp\www\dragon_game\dragon_game\ability_points.php on line 45

Notice:  Undefined index: charisma in C:\wamp\www\dragon_game\dragon_game\ability_points.php on line 45
and the $_POST array is not being set from my form. Any help greatly appreciated. Here is my code. Thanks. Derek

Code:
<?php
session_start();

// permanent character ability points assigned from form into these session vars
$_SESSION['playerStrength']='';
$_SESSION['playerWisdom']='';
$_SESSION['playerCharisma']='';
$_SESSION['playerConstitution']='';
$_SESSION['playerIntelligence']='';
$_SESSION['playerDexterity']='';

///variables to say that the number has already been used
$sixteenUsed='';
$fourteenUsed='';
$thirteenUsed='';
$twelveUsed='';
$elevenUsed='';
$tenUsed='';
//////////////////////////
$playerStrength='';
$playerWisdom='';
$playerCharisma='';
$playerIntelligence='';
$playerDexterity='';
$playerConstitution='';

$assignMessage='';


//ability points to disappear after used

$sixteen='16';
$fourteen='14';
$thirteen='13';
$twelve='12';
$eleven='11';
$ten='10';


/////////////////////////////////////////////////////////////////////////////////////
echo "<pre>".print_r($_POST, 1)."</pre>";
//if 16 already used from form, echo out nothing instead of '16' at the top of page.
//then make the number Used equal to true so we can use it later
if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='16')
{
$sixteen=''; 
$sixteenUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='14')
{
$fourteen=''; 
$fourteenUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='13')
{
$thirteen=''; 
$thirteenUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='12')
{
$twelve=''; 
$twelveUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='11')
{
$eleven='';
$elevenUsed=true; 
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='10')
{
$ten=''; 
$tenUsed=true;
}

////////////////////////////////////////////////////////////////////////////////////

//if they've already assigned this point, say sorry message, otherwise, assign point.
if(!empty($_POST['strength']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerStrength']=$_POST['strength'];
        $assignMessage='You have assigned '.$_SESSION['playerStrength'].' to Strength';
    }
}
if(!empty($_POST['wisdom']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerWisdom']=$_POST['wisdom'];
        $assignMessage='You have assigned '.$_SESSION['playerWisdom'].' to Wisdom';
    }
}
if(!empty($_POST['charisma']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerCharisma']=$_POST['charisma'];
        $assignMessage='You have assigned '.$_SESSION['playerCharisma'].' to Charisma';
    }
}
if(!empty($_POST['constitution']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerConstitution']=$_POST['constitution'];
        $assignMessage='You have assigned '.$_SESSION['playerConstitution'].' to Constitution';
    }
}
if(!empty($_POST['intelligence']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerIntelligence']=$_POST['intelligence'];
        $assignMessage='You have assigned '.$_SESSION['playerIntelligence'].' to Intelligence';
    }
}
if(!empty($_POST['dexterity']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerDexerity']=$_POST['strength'];
        $assignMessage='You have assigned '.$_SESSION['playerDexterity'].' to Dexterity';
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Dereks Dragon Game</title>
<style type="text/css">
table {
width: 30%;
background-color:#CCCCCC;
border: 1px white solid;
}
</style>

</head>
<body>
<h3 align="center"> Welcome to Derek's Dragon Games</h3>
<br /><br /><p align='center'> <a href="choose_class.php">Go back to Class choose menu</a></p><br /><br />
<p align="center">Please assign the following ability points to your Abilities for your <?php echo "<strong>".$_SESSION['race']." ".$_SESSION['class']."</strong>.";?><br /><br /></p>
<p align="center"><strong><?php echo $sixteen.", ".$fourteen .", ". $thirteen.", ".$twelve.", ".$eleven.", ".$ten.". ";?></strong></p> 

<strong>Abilities:</strong><br /><br />
<?php echo $assignMessage;?>
<table><tr><td><strong>Strength (Str):</strong> measures your character’s physical
power. It’s important for most characters who fight
hand-to-hand. Clerics, fighters, paladins, rangers, and warlords have powers based on Strength.</td></tr>
 </table>
 <table> 
<tr><td><form><strong>Strength:</strong><input type="text" action="ability_points.php" size="10" maxlength="2" method="post"> <input type="submit"  value="Assign Points" name="strength"/> </form></td></tr> 
</table><br />

<table><tr><td><strong>Constitution: (Con)</strong> represents your character’s
health, stamina, and vital force. All characters benefit from a high Constitution score. Many warlock powers are based on Constitution.</td></tr></table><table> 
<tr><td><form><strong>Constitution:</strong><input type="text" action="ability_points.php" size="10" maxlength="2" method="post"> <input type="submit"  value="Assign Points" name="contitution"/> </form></td></tr> 
</table><br />

<table><tr><td><strong>Dexterity:</strong>measures hand-eye coordination,
agility, reflexes, and balance. Many ranger and rogue powers are based on
Dexterity.</td></tr>
</table><table> 
<tr><td><form><strong>Dexterity:</strong><input type="text" action="ability_points.php" size="10" maxlength="2" method="post"> <input type="submit"  value="Assign Points" name="dexterity"/> </form></td></tr> 
</table><br /><br />
 
<table><tr><td><strong>Intelligence (Int):</strong> Intelligence (Int) describes how well your character
learns and reasons. Wizard powers are based on Intelligence.</td></tr></table>
 <table> 
<tr><td><form><strong>Intelligence:</strong><input type="text" action="ability_points.php" size="10" maxlength="2" method="post"> <input type="submit"  value="Assign Points" name="intelligence"/> </form></td></tr> 
</table><br />
<br /> 
<table><tr><td><strong>Wisdom (Wis):</strong> measures your common sense, perception,
self-discipline, and empathy. You use your Wisdom score to notice details, sense danger, and get a
read on other people.Many cleric powers are based on Wisdom.</td></tr></table>
<table> 
<tr><td><form><strong>Wisdom:</strong><input type="text" action="ability_points.php" size="10" maxlength="2" method="post"> <input type="submit"  value="Assign Points" name="wisdom"/> </form></td></tr> 
</table><br /><br /> 

<table><tr><td><strong>Charisma (Cha):</strong> measures your force of personality,
persuasiveness, and leadership.Many paladin and warlock powers are based on
Charisma.</td></tr></table>
<table> 
<tr><td><form><strong>Charisma:</strong><input type="text" action="ability_points.php" size="10" maxlength="2" method="post"> <input type="submit"  value="Assign Points" name="charisma"/> </form></td></tr> 
</table><br /><br /> 
<br /> 
</table>
</body>
</html>
silverglade is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-23-2010, 11:33 AM Re: getting undefined error message and $_POST array not filling
Webmaster Talker

Posts: 611
Trades: 0
I fixed the form tags, but I still get the errors on loading the page, any help appreciated. thanks . Derek

Here is the new code with form tags fixed.

Code:
<?php
session_start();

// permanent character ability points assigned from form into these session vars
$_SESSION['playerStrength']='';
$_SESSION['playerWisdom']='';
$_SESSION['playerCharisma']='';
$_SESSION['playerConstitution']='';
$_SESSION['playerIntelligence']='';
$_SESSION['playerDexterity']='';

///variables to say that the number has already been used
$sixteenUsed='';
$fourteenUsed='';
$thirteenUsed='';
$twelveUsed='';
$elevenUsed='';
$tenUsed='';
//////////////////////////
$playerStrength='';
$playerWisdom='';
$playerCharisma='';
$playerIntelligence='';
$playerDexterity='';
$playerConstitution='';

$assignMessage='';


//ability points to disappear after used

$sixteen='16';
$fourteen='14';
$thirteen='13';
$twelve='12';
$eleven='11';
$ten='10';


/////////////////////////////////////////////////////////////////////////////////////
echo "<pre>".print_r($_POST, 1)."</pre>";
//if 16 already used from form, echo out nothing instead of '16' at the top of page.
//then make the number Used equal to true so we can use it later
if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='16')
{
$sixteen=''; 
$sixteenUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='14')
{
$fourteen=''; 
$fourteenUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='13')
{
$thirteen=''; 
$thirteenUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='12')
{
$twelve=''; 
$twelveUsed=true;
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='11')
{
$eleven='';
$elevenUsed=true; 
}

if($_POST['strength'] || $_POST['wisdom'] || $_POST['charisma'] || $_POST['dexterity']
|| $_POST['constitution'] || $_POST['intelligence']=='10')
{
$ten=''; 
$tenUsed=true;
}

////////////////////////////////////////////////////////////////////////////////////

//if they've already assigned this point, say sorry message, otherwise, assign point.
if(!empty($_POST['strength']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerStrength']=$_POST['strength'];
        $assignMessage='You have assigned '.$_SESSION['playerStrength'].' to Strength';
    }
}
if(!empty($_POST['wisdom']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerWisdom']=$_POST['wisdom'];
        $assignMessage='You have assigned '.$_SESSION['playerWisdom'].' to Wisdom';
    }
}
if(!empty($_POST['charisma']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerCharisma']=$_POST['charisma'];
        $assignMessage='You have assigned '.$_SESSION['playerCharisma'].' to Charisma';
    }
}
if(!empty($_POST['constitution']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerConstitution']=$_POST['constitution'];
        $assignMessage='You have assigned '.$_SESSION['playerConstitution'].' to Constitution';
    }
}
if(!empty($_POST['intelligence']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerIntelligence']=$_POST['intelligence'];
        $assignMessage='You have assigned '.$_SESSION['playerIntelligence'].' to Intelligence';
    }
}
if(!empty($_POST['dexterity']))
{
    if($tenUsed || $elevenUsed || $twelveUsed || $thirteenUsed || $fourteenUsed || $sixteenUsed)
    {
        $usedMessage='Sorry you have already used this number.';
    }
    else
    {
        $_SESSION['playerDexerity']=$_POST['strength'];
        $assignMessage='You have assigned '.$_SESSION['playerDexterity'].' to Dexterity';
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Dereks Dragon Game</title>
<style type="text/css">
table {
width: 30%;
background-color:#CCCCCC;
border: 1px white solid;
}
</style>

</head>
<body>
<h3 align="center"> Welcome to Derek's Dragon Games</h3>
<br /><br /><p align='center'> <a href="choose_class.php">Go back to Class choose menu</a></p><br /><br />
<p align="center">Please assign the following ability points to your Abilities for your <?php echo "<strong>".$_SESSION['race']." ".$_SESSION['class']."</strong>.";?><br /><br /></p>
<p align="center"><strong><?php echo $sixteen.", ".$fourteen .", ". $thirteen.", ".$twelve.", ".$eleven.", ".$ten.". ";?></strong></p> 

<strong>Abilities:</strong><br /><br />
<?php echo $assignMessage;?>
<table><tr><td><strong>Strength (Str):</strong> measures your character’s physical
power. It’s important for most characters who fight
hand-to-hand. Clerics, fighters, paladins, rangers, and warlords have powers based on Strength.</td></tr>
 </table>
 <table> 
<tr><td><form action="ability_points.php" method="post"><strong>Strength:</strong><input type="text"  size="10" maxlength="2" > <input type="submit"  value="Assign Points" name="strength"/> </form></td></tr> 
</table><br />

<table><tr><td><strong>Constitution: (Con)</strong> represents your character’s
health, stamina, and vital force. All characters benefit from a high Constitution score. Many warlock powers are based on Constitution.</td></tr></table><table> 
<tr><td><form action="ability_points.php" method="post"><strong>Constitution:</strong><input type="text" size="10" maxlength="2" > <input type="submit"  value="Assign Points" name="contitution"/> </form></td></tr> 
</table><br />

<table><tr><td><strong>Dexterity:</strong>measures hand-eye coordination,
agility, reflexes, and balance. Many ranger and rogue powers are based on
Dexterity.</td></tr>
</table><table> 
<tr><td><form action="ability_points.php" method="post"><strong>Dexterity:</strong><input type="text"   size="10" maxlength="2"  > <input type="submit"  value="Assign Points" name="dexterity"/> </form></td></tr> 
</table><br /><br />
 
<table><tr><td><strong>Intelligence (Int):</strong> Intelligence (Int) describes how well your character
learns and reasons. Wizard powers are based on Intelligence.</td></tr></table>
 <table> 
<tr><td><form action="ability_points.php" method="post"><strong>Intelligence:</strong><input type="text" size="10" maxlength="2""> <input type="submit"  value="Assign Points" name="intelligence"/> </form></td></tr> 
</table><br />
<br /> 
<table><tr><td><strong>Wisdom (Wis):</strong> measures your common sense, perception,
self-discipline, and empathy. You use your Wisdom score to notice details, sense danger, and get a
read on other people.Many cleric powers are based on Wisdom.</td></tr></table>
<table> 
<tr><td><form action="ability_points.php" method="post"><strong>Wisdom:</strong><input type="text"  size="10" maxlength="2"  > <input type="submit"  value="Assign Points" name="wisdom"/> </form></td></tr> 
</table><br /><br /> 

<table><tr><td><strong>Charisma (Cha):</strong> measures your force of personality,
persuasiveness, and leadership.Many paladin and warlock powers are based on
Charisma.</td></tr></table>
<table> 
<tr><td><form action="ability_points.php" method="post"><strong>Charisma:</strong><input type="text" size="10" maxlength="2" > <input type="submit"  value="Assign Points" name="charisma"/> </form></td></tr> 
</table><br /><br /> 
<br /> 
</table>
</body>
</html>
silverglade is offline
Reply With Quote
View Public Profile
 
Old 07-30-2010, 08:38 AM Re: getting undefined error message and $_POST array not filling
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
check that a form HAS been submitted on opening the page
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-30-2010, 09:45 AM Re: getting undefined error message and $_POST array not filling
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Also, make sure that the form you're using is actually method="post". It should be obvious when you submit it, but I have to ask.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-30-2010, 10:19 AM Re: getting undefined error message and $_POST array not filling
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Paste your form source.
Evidently some values just are not being sent..
Bad spelling? Wrong name in wrong bit?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Reply     « Reply to getting undefined error message and $_POST array not filling
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22416 seconds with 12 queries