im using a form to select from 3 images send a post to a php but the $_POST['stars']; is not getting there
<form action="components/update_score.php" method="POST">
<input type="image" name="stars" src="imagenes/th/0.png" value="0" width="120" />
<input type="image" name="stars" src="imagenes/th/1.png" value="1" width="120" />
<input type="image" name="stars" src="imagenes/th/2.png" value="2" width="120" />
<input type="image" name="stars" src="imagenes/th/3.png" value="3" width="120" />
<input type="hidden" name="war_enemy" value="<?php echo $rws['war_enemy'];?>" />
<input type="hidden" name="user_username" value="<?php echo $user_score;?>" />
<input type="hidden" name="enemy_enemynumber" value="<?php echo $i;?>" />
</form>
and on the php
<?php
ini_set("display_errors",1);
session_start();
if(isset($_POST)){
echo $_POST['stars'],'<br>';
echo $_POST['war_enemy'],'<br>';
echo $_POST['user_username'],'<br>';
echo $_POST['enemy_enemynumber'],'<br>';
}
?>
sending this give me the Notice: Undefined index: stars i dont want to use a submit button i want to use the images to do so but cant find the way to send the post to the php any help is appreciated
You have 3 images with the same name change their name or you can use an array renaming stars as stars[] and your code will be something like this:
foreach ($_POST['stars'] as $star) {
echo $star;
}
Also instead of src you need to add your image at value and please delete the src as you are using an input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With