type='image'的值怎么post到php?最近在做zencart网店系统安装一个收藏夹插件遇到一个奇怪的事情
form底下有2个按钮,
一个是收藏夹按钮
<input type="image" value="yes" name="wishlist" title=" Add to Wish List " alt="Add to Wish List" src="includes/templates/template_default/buttons/english/wishlist_add.gif">一个是购物车按钮
<input type="image" title=" Add to Cart " alt="Add to Cart" src="includes/templates/template_default/buttons/english/button_in_cart.gif">按常理来说,2个按钮都是提交form使用的,但实际上按2个按钮却实现不一样的功能,确定了没有js影响。我做了个简单的实验,看是否能提交图片按钮的值,貌似不行,求大师解答,怎么post image的值?
<?php
@$text=$_POST['text'];
@$d=$_POST['d'];
if($text){echo $text;}
if($d){echo $d;}?>
<form name="form1" action="laji.php" method="post">
<input type="text" name="text" />
<input  name='d' type='image' value='hello world'/>
<button type='submit'>submit</button>
</form>

解决方案 »

  1.   

    echo $_POST['d'];<input  name='d' type='image' value='hello world'/>
    是作为提交按钮使用的
    所以当点击 <button type='submit'>submit</button> 时 hello world 不会被提交你把php部分写成 print_r($_POST); 就都清楚了
      

  2.   

    能说说
    一个是收藏夹按钮
    <input type="image" value="yes" name="wishlist" title=" Add to Wish List " alt="Add to Wish List" src="includes/templates/template_default/buttons/english/wishlist_add.gif">一个是购物车按钮
    <input type="image" title=" Add to Cart " alt="Add to Cart" src="includes/templates/template_default/buttons/english/button_in_cart.gif">点击不同的按钮,会跳转到不同的页面,没有js干扰,这是什么回事?
      

  3.   

    一个是收藏夹按钮
    <input type="image" value="yes" name="wishlist" title=" Add to Wish List " alt="Add to Wish List" src="includes/templates/template_default/buttons/english/wishlist_add.gif">一个是购物车按钮
    <input type="image" title=" Add to Cart " alt="Add to Cart" src="includes/templates/template_default/buttons/english/button_in_cart.gif">点击2个按钮能跳转到2个不同地页面,使用的是同一个form,没有js作用,这是什么回事?
      

  4.   

    name="wishlist"
    购物车 的可能是贴漏了总之,不同的 name 做不同的事情
      

  5.   

    上传图片用:<input type="file" name="upImg" value="" title="上传图片" />楼主说的情况,在form中看看action指向哪里?是否有不同情况下判断出的参数。
    如果还是这情况,那楼主去你的代码其他地方找找,不可能没有js控制就跳至不同页面了。