Cetanu Posted August 20, 2009 Share Posted August 20, 2009 Okay, here is my 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; } #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 if(!$_POST['cont']){ echo " Time to create your character!<br/> <form action='create.php' method='post'> <fieldset> <legend>Create Character for <u><i>YOU CAN USE MEMBER'S NAME HERE!!!</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' value='Enter Character Name Here' id='name' name='name'/><br/> <label for='player'>Your Name</label> <input type='text' maxlength='30' value='{$_SESSION['username']}' id='player' name='player' readonly='readonly'/><br/> <input type='submit' name='cont' id='cont' value='Continue On'/> </fieldset> </form>"; } ?> <br/> <?php if($_POST['cont']){ if($_POST['Species'] != "Alien" || "Predator" || "Marine"){ echo "You do not have the correct species. Try again. <a href=\"create.php\" title='Click to Reload'>Click to Reload Page</a>"; } else{ include "db.php"; mysql_query("INSERT INTO rpg (name, species, player) VALUES ('{$_POST['name']}' , '{$_POST['Species']}' , '{$_POST['player']}')") or die(mysql_error()); echo "Success!"; } } ?> </div> </body> </html> In these lines: <?php if($_POST['cont']){ if($_POST['Species'] != "Alien" || "Predator" || "Marine"){ echo "You do not have the correct species. Try again. <a href=\"create.php\" title='Click to Reload'>Click to Reload Page</a>"; } else{ include "db.php"; mysql_query("INSERT INTO rpg (name, species, player) VALUES ('{$_POST['name']}' , '{$_POST['Species']}' , '{$_POST['player']}')") or die(mysql_error()); echo "Success!"; } } ?> I want to make sure that those sneaky people with Firebug don't mess with the choices. However, when I select an option that IS right it still gives me the error about having an incorrect species chosen. It used to work until I added in the stuff about inserting into PLAYER and using $_POST['player'] for the value. Help? EDIT: It also will not insert my data for some reason. Link to comment https://forums.phpfreaks.com/topic/171090-solved-simple-if-else-problem/ Share on other sites More sharing options...
oni-kun Posted August 20, 2009 Share Posted August 20, 2009 In the IF you have to define each statement, you can't use OR operator to repeat them. if($_POST['Species'] != 'Alien' || $_POST['Species'] != 'Predator' || $_POST['Species'] != 'Marine'){ Or else it'd just appear as.. 'if("Preditor")' and that'd be invalid to parse. Link to comment https://forums.phpfreaks.com/topic/171090-solved-simple-if-else-problem/#findComment-902280 Share on other sites More sharing options...
Cetanu Posted August 20, 2009 Author Share Posted August 20, 2009 Nope, still nothing. It worked before I added in the stuff about Inserting "player". >_> Link to comment https://forums.phpfreaks.com/topic/171090-solved-simple-if-else-problem/#findComment-902282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.