如果图像用作按钮,则图像ID不会发送到服务器

时间:2016-11-16 19:31:00

标签: php

我试图将图像的ID发送到用作的服务器  图像按钮在这里,但每次错误的ID被发送到 服务器的数据库。无论选择哪个图像,警告框都是 始终显示相同的消息。

// file named as  garbage.php
<form>
<input type="hidden"  name="sub1" id="sub1" value="<?php echo "$merge1";?>">
<input type="image" src="survey_photos/<?php echo "$merge1.jpg";?>"
 alt="<?    php echo "$merge1";?>"  style="width:230px;height:300px">
<input type="hidden"  name="sub2" id="sub2" 
value="<?php echo "$merge2";?    >"/>
<input type="image" src="survey_photos/<?php echo "$merge2.jpg";?>" 
alt="<?  php echo "$merge2";?>"  style="width:230px;height:300px">
</form>
//*server script* sending either image1 or image2
<?php
if(isset($_GET['sub1']))
{
if(mysqli_query($link1,"insert into result values('$user','$merge1','$sid',NOW())"))
{
echo '<script>alert(" submitted 1");window.location.href="garbage.php"    </script>';

}
else
{
echo '<script>alert(" not submitted 1");window.location.href="garbage.php"   </script>';

}
}
else if(isset($_GET['sub2']))
{
    echo "varsha";
    if(mysqli_query($link1,
"insert into result    values('$user','$merge2','$sid',NOW())"))
echo '<script>alert("submitted 2");window.location.href="garbage.php"</script>';
else
echo '<script>alert("not submitted 2");window.location.href="garbage.php"</script>';
}

?>

0 个答案:

没有答案