在脚本之间传递值: [英] Passing values between scripts:

查看:78
本文介绍了在脚本之间传递值:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我想知道是否有人可以提供一些关于我的PHP脚本的指导。我希望这个例子允许用户点击提交

按钮和项目编号增量。


当用户点击,我的购物篮图标items.php脚本

启动,当前脚本中的变量传递给它。


我试图显示随着项目的增加变量,尽管

我没有任何价值。任何人都可以看到逻辑错误吗?


谢谢


<?php

global $ item1,$ item2;


if(isset($ _ GET [''item1''])){

$ item1 ++;

}

if(isset($ _ GET [''item2''])){

$ item2 ++;

}

?>


< head>

< title> PHP示例< / title>

< / head>


< body>

< p>

< table border =" 0" width =" 100%">

< tr>

< td>

< a>< img src =" mybasket.jpg">< / a>

< / td>

< / tr>

< / table>

< / p>


< form method = post>

< table border =" 0" width =" 79%">


< tr>

< td>

<输入类型= [提交" name =" item1" value ="添加item1">

< / td>

< td>

< input type =" submit" ; name =" item2" value ="添加item2">

< / td>

< / tr>


< /表格>

< / form>


< / body>

< / html>

解决方案

item1,


item2;


if(isset(

_GET [''item1''])){


Hello,

I wondered if anyone could offer some guidance over my php script. I
was hoping the example would allow the user to click the submit
buttons and the item number increment.

And when the user clicks, the my basket icon the items.php scripts
starts and the variables from the current script are passed to this.

I tried to display the variables as the items are incremented, though
I got no value. Can anyone see the logical error?

Thank you

<?php
global $item1, $item2;

if(isset($_GET[''item1''])){
$item1++;
}
if(isset($_GET[''item2''])){
$item2++;
}
?>

<head>
<title>PHP Example</title>
</head>

<body>
<p>
<table border="0" width="100%">
<tr>
<td>
<a><img src="mybasket.jpg"></a>
</td>
</tr>
</table>
</p>

<form method=post>
<table border="0" width="79%">

<tr>
<td>
<input type="submit" name = "item1" value = "Add item1">
</td>
<td>
<input type="submit" name = "item2" value = "Add item2">
</td>
</tr>

</table>
</form>

</body>
</html>

解决方案

item1,


item2;

if(isset(


_GET[''item1''])){


这篇关于在脚本之间传递值:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆