Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dear Santa...Claus
12-25-2010, 10:05 PM,
Post: #1
Dear Santa...Claus
Code:
<?php
mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("card") or die(mysql_error());

error_reporting (E_ALL ^ E_NOTICE);
class card
{
    public $type;
    public $name;
    public function card($a,$b)
    {    
        $this->type = $a;
        $this->name = $b;
        $cardtype = new cardType($this->type,$this->name);
    }
}
class cardType extends card
{
    public function cardType($x,$y)
    {
        if ($x == "equipment" || $x == "spell" || $x == "character" || $x == "trap")
        {
            echo "Card created type: ".$x." name: ".$y."<br />";
            $this->giveType($x,$y);
        }
        else
        {
            echo "Card type '".$x."' does not exist";
        }
    }
    public function giveType($a,$b)
    {
        echo "What will card do?";
        if ($a == "trap")
        {
            ?>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" />
            <p>Enter Damage Amount Card Will Deal: <input type="textbox" name="damagevalue" /></p>
            <input type="radio" name="damage" value="lightning"/>Lightning<br />
            <input type="radio" name="damage" value="fire"/>Fire<br />
            <input type="radio" name="damage" value="pain"/>Pain<br />
            <input type="submit" value="Submit Values" />
            <?php
            $damagevalue = $_POST['damagevalue'];
            $traptype = $_POST['damage'];
            if ($damagevalue > 0)
            {
                echo $a." card named ".$b." deals ".$traptype." damage of ".$damagevalue;
                mysql_query("INSERT INTO createCard(name,type,trap) VALUES('".$b."','".$a."','".$traptype."') ") or die(mysql_error());
            }
        }
        if ($a == "equipment")
        {
            ?>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" />
            <p>What Type of Equipment and Bonus Stats:</p><br />
            <input type="radio" name="equip" value="armor"/>Armor<br />
            <input type="radio" name="equip" value="amulet"/>Amulet<br />
            <input type="radio" name="equip" value="helm"/>Helm<br />
            <input type="radio" name="equip" value="weapon"/>Weapon<br />
            <input type="radio" name="equip" value="shield"/>Shield<br />
            <input type="textbox" name="value" />
            <input type="submit" value="Submit Values" />
            <?php
            $damvalue = $_POST['value'];
            $equipment = $_POST['equip'];
            if ($damvalue > 0)
            {
                echo $a." card named ".$b." deals ".$equipment." damage bonus of ".$damvalue;
                mysql_query("INSERT INTO createCard(name,type,equiptype,numbervalue) VALUES('".$b."','".$a."','".$equip."','".$damvalue."') ") or die(mysql_error());
            }
        }
        if ($a == "spell")
        {
            ?>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" />
            <p>What Damage Will the Spell Deal: <input type="textbox" name="damagevalue" /></p>
            <input type="radio" name="spell" value="water"/>Water<br />
            <input type="radio" name="spell" value="fire"/>Fire<br />
            <input type="radio" name="spell" value="nature"/>Nature<br />
            <input type="radio" name="spell" value="air"/>Air<br />
            <input type="radio" name="spell" value="stone"/>Stone<br />
            <input type="submit" value="Submit Values" />
            <?php
            $spelltype = $_POST['spell'];
            $damagevalue = $_POST['damagevalue'];
            if ($damagevalue > 0)
            {
                echo $a." card named ".$b." deals ".$spelltype." damage of ".$damagevalue;
                mysql_query("INSERT INTO createCard(name,type,element,numbervalue) VALUES('".$b."','".$a."','".$spelltype."','".$damagevalue."') ") or die(mysql_error());
            }
        }
        if ($a == "character")
        {
            ?>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" />
            <p>What Type of Character: <input type="radio" name="sex" value="male" />Male <input type="radio" name="sex" value="female" />Female</p><br />
            <input type="radio" name="char" value="hound"/>Hounzalid<br />
            <input type="radio" name="char" value="rhizard"/>Rhizard<br />
            <input type="radio" name="char" value="human"/>Human<br />
            <input type="radio" name="char" value="undead"/>Undead<br />
            <input type="radio" name="char" value="eldron"/>Eldron<br />
            <input type="submit" value="Submit Values" />
            <?php
            $sex = $_POST['sex'];
            $character = $_POST['char'];
            if (isset($_POST['sex']) || isset($_POST['char']))
            {
                echo $a." card named ".$b." is a ".$character." that is a ".$sex;
                mysql_query("INSERT INTO createCard(name,type,race,gender) VALUES('".$b."','".$a."','".$character."','".$sex."') ") or die(mysql_error());
            }
        }
        
    }
}
?>
<form method ="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" />
<p>Enter Card Type: <input name="type" type="radio" value="character"/>Character<input name="type" type="radio" value="spell"/>Magic Spell<input name="type" type="radio" value="equipment"/>Equipment<input name="type" type="radio" value="trap"/>Trap</p>
<p>Enter Card Name: <input name="name" type="textbox"/></p>
<input type="submit" value="Create Card" />
<br /><br />
<?php
$cname = $_POST['name'];
$ctype = $_POST['type'];
$lengthn = strlen($cname);
if ($lengthn > 1 && $ctype !== " ")
{
    $card = new card($ctype,$cname);
}
?>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)