My PHP code will only execute the first part of my code...
Code: <?php
session_start();
?>
<html>
<head>
<title> Create a Character</title>
<style type="text/css">
body{
background-color: #000;
font-family: Arial, Tahoma;
font-size: .78em;
}
fieldset{
padding: 10px;
margin: 10px;
border: 1px solid #57626B;
width: 70%;
float: left;
}
legend{
background-color: #6A8CA5;
border: 1px solid #000;
padding: 5px;
}
input{
font-style: italic;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#tester{
background-color: #333;
margin: 0 auto;
padding: 10px;
width: 70%;
height: 80%;
}
#stats{
float: left;
width: 25%;
font-style: italic;
color: #000;
padding: 5px;
border: 1px dashed #999;
}
</style>
</head>
<body>
<div id="tester">
<?php
//Creation script designed by Cetanu of http://mythscape.freezoka.com and http://tehfreerpg.proboards.com
//This script is licensed by the Creative Commons for: Sharing, Attribution, Non-derivative, and non-commercial.
//You MUST leave these notices in for LEGAL use of this script. YOU MAY NOT EDIT THIS SCRIPT LEGALLY.
//For more: http://creativecommons.org/licenses/by-nc-nd/3.0/us/
if(empty($_SESSION['user_id'])){
die("<strong>You are not logged in. Please do so to access the RPG Sector.</strong>");
}
if(empty($_POST['cont'])){
echo " Time to create your character!<br/>
<form action='create.php' method='post'>
<fieldset>
<legend>Create Character for <strong>".$_SESSION['user_id']."</strong></i></u></legend>
<p>Please choose a species.</p>
<input type='radio' name='Species' id='pred' value='Predator'/>Predator (Yautja)<br/>
<input type='radio' name='Species' id='alien' value='Alien'/>Alien (Xenomorph)<br/>
<input type='radio' name='Species' id='human' value='Marine'/>Marine<br/> <br/>
<label for='name'>Character Name</label>
<input type='text' maxlength='25' id='name' name='name'/><br/>
<input type='hidden' maxlength='30' value='{$_SESSION['user_id']}' id='player' name='player' readonly='readonly'/><br/>
<input type='submit' name='cont' id='cont' value='Continue On'/>
</fieldset>
</form>";
}
echo "<br/>";
if(!empty($_POST['cont'])){
$species = $_POST['species'];
include "db.php";
if(empty($_POST['name']) || empty($_POST['Species'])){
echo "<script>document.write('You must input a species and a name!'); setTimeout("window.location.reload()", 350);</script>";
}
if ($species== "Predator" || "Alien" || "Marine" && !empty($_POST['name'])){
mysql_query("INSERT INTO rpg (name, species, player) VALUES ('{$_POST['name']}' , '{$_POST['Species']}' , '{$_POST['player']}')")
or die(mysql_error());
}
elseif($species=="Predator"){
mysql_query("UPDATE rpg SET max_health=25, health=25, attack=25, defense=25, honor=20 WHERE player='{$_POST['player']}')");
}
elseif($species=="Alien"){
mysql_query("UPDATE rpg SET health=20, max_health=20, attack=20 , defense=20 , stealth=20 WHERE player='{$_POST['player']}");
}
elseif($species=="Marine"){
mysql_query("UPDATE rpg SET health=15, max_health=15 , attack=20 , defense=20 , melee=20 WHERE player='{$_POST['player']}");
}
else{
echo "Invalid Species. Try again!";
}
mysql_query("INSERT INTO bank (player , amount) VALUES('{$_SESSION['user_id']}' , 5)");
header('Location: statadd.php');
}
?>
</div>
</body>
</html>
The part starts here...When it gets to the three elseif statements, they are the only things that won't execute. Everything else works. I don't get errors.
Code: <?php
if(!empty($_POST['cont'])){
$species = $_POST['species'];
include "db.php";
if(empty($_POST['name']) || empty($_POST['Species'])){
echo "<script>document.write('You must input a species and a name!'); setTimeout("window.location.reload()", 350);</script>";
}
if ($species== "Predator" || "Alien" || "Marine" && !empty($_POST['name'])){
mysql_query("INSERT INTO rpg (name, species, player) VALUES ('{$_POST['name']}' , '{$_POST['Species']}' , '{$_POST['player']}')")
or die(mysql_error());
}
elseif($species=="Predator"){
mysql_query("UPDATE rpg SET max_health=25, health=25, attack=25, defense=25, honor=20 WHERE player='{$_POST['player']}')");
}
elseif($species=="Alien"){
mysql_query("UPDATE rpg SET health=20, max_health=20, attack=20 , defense=20 , stealth=20 WHERE player='{$_POST['player']}");
}
elseif($species=="Marine"){
mysql_query("UPDATE rpg SET health=15, max_health=15 , attack=20 , defense=20 , melee=20 WHERE player='{$_POST['player']}");
}
else{
echo "Invalid Species. Try again!";
}
mysql_query("INSERT INTO bank (player , amount) VALUES('{$_SESSION['user_id']}' , 5)");
header('Location: statadd.php');
}
?>
php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from the sql. However when I click delete nothing happens.Code:
FPDF Help
I've been playing with the FPDF module. I was building a form and rolling right along and then suddenly I started getting the "FPDF error: Some data has already been output, can't send PDF
Alternate messaging
I have 4 strings in MySQL db1$string1 : Hello$string2 : Hi$string3 : Great$string4 : ThanksAnd I have 3 accounts MySQL db2$User1 : $Pw1$User2 : $Pw2$User3 : $Pw3expected result---------------Hello
PHP - HTML
Could anyone give me some GOOD sample links for php - html email tutorial.Thanks!
Do While statement
hi guys,This may sound trivial but im new to php and as part of an assignmenti have to construct the 10 green bottles song using the do while statement. I can do the statement but it is itengrating
Last character removed
I have created a string from an array. I have inserted commas from my form values. I am trying to remove the last comma from the string and can't seem to remove it. I have tried chop, rtrim, substr,
if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough to do, but I'm flailing here...I need to have a blurb that checks to see if a cookie of a specific
Simple Variable Question
Hi everyone.... again,I am really getting into php still. Learning more every day. I love it.But I have run into a problem I cannot solve.From what I understand, you can only "echo
dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button that i would like to have it when selected and i hit either edit or delete the ID is passed to another
Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.It'll do the query and then do..$views = $row['views'] + 1;Then insert $views into the database.This updates the view for each refresh of