作者sskywind (有股蛋蛋的哀伤..)
看板PHP
标题[请益] 同一个 php页面的传值
时间Mon Mar 13 22:25:11 2006
我想要把 record_num,在每次使用者输入一个「数字」存在 first的input里面时,
按下submit,可以纪录到 cookie 里面,并且把 record_num + 1,
然後会再 load 一次同一个页面,并且把所有输入过的input依序列出来,
再让使用者继续输入下一个数值。可以重复以上动作。
下面是我的code,一直try不出来,麻烦帮我看错在哪里 ><,谢谢。
<?php
if($record_num){
$a_record = $first;
setcookie("c_record[$record_num]", $a_record);
$record_num++;
}else{
$record_num = 1;
}
?>
<html>
<head>
...
</head>
<body>
<?php
$first = $_POST['first'];
echo '<form action=try.php method="post">';
$a_record = $first;
$HTTP_COOKIE_VARS['c_record'][$record_num-1] = $a_record;
for($i=0;$i<$record_num;$i++){
echo $HTTP_COOKIE_VARS['c_record'][$i];
}
echo '<p>record_num</p>'.$record_num.'<br />';
echo '<input type="text" name="first" size="12" maxlength="10" />';
echo '<input type="hidden" name="record_num" value=$record_num />';
echo '<input type="submit" value="确定" />';
echo '</form>';
?>
<a href=try.php?record_num=<?echo $record_num?>>确定</a>
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.167.233.118
1F:推 hellolucky:$record_num的初始值在哪阿? 03/14 00:19
2F:→ hellolucky:没事 我看到了@@" 03/14 00:20