I have a bit of code in which I want a form to appear when the New Player button is clicked. My problem is when I click on the submit button in the form, the validation code does not run. I'm not sure how to force the function to retain control.
The original New Player button calls an external PHP script
echo "<form action = '', method = 'post'>";
echo "<button name = 'showPF', type = 'submit', value = 'New Player'>New Player</button></br>";
echo "</form>";
if(isset( $_POST['showPF'])) {
require(__DIR__.'/new_player.php');
}
The form is then shown and in turn calls a function. This function is the part that never gets executed.
echo "<form action = '' method='post'>";
echo "Player Name: <input type='text' name='playerName'></br>";
echo "Character Name: <input type='text' name ='charName'></br>";
echo "Class: <input type='text' name = 'class'></br>";
echo "Race: <input type='text' name = 'race'></br>";
echo "Level: <input type = 'int' name = 'level'></br>";
echo "<button name='add', type = 'submit', value = 'Add Player'>Add Player</button></br>";
echo "</form>";
if(isset($_POST['add'])){
addPlayer();
}
Since I don't know why it's not completing the second if statement I'm not sure how to google my answer.
Thank you for your time.
Aucun commentaire:
Enregistrer un commentaire