有两页。在第1页中,用户输入一个数字,并相应地从db获取数据。在第2页中,用户对数据执行一些操作,并在page2中按submit,然后将用户在第一页中提交的id或值随页2中的数据更改而存储。i应该将已更改的数据i页2以id存储在page1中。我无法存储第一页的输入。我对php很陌生。这是代码
第1页:
<form name="VAL" action="ty.php" method="POST">
<?php
echo "<input type=\"number\" name=\"j\" value=\"j\"class=\"input\" min=\"1\" max =\"2000\">
echo "<input type=\"submit\" name=\"submit1\" value=\"choice1\"class=\"button\">
?>第2页:
<?php
$ytr=$_post['j'];//The value of number entered by user in page 1 this is not saving in db
$wer=$_POST['hi'];
if($_SERVER['REQUEST_METHOD'] == 'POST'&& $_POST['submit2']=='choice2')
{
$con = mysql_connect("localhost","root","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ram", $con);
$sqlCmd = sprintf("INSERT INTO outp (tweet,Mtweet) VALUES ('%s','%s')",
mysql_real_escape_string($ytr),
mysql_real_escape_string($wer));
mysql_query($sqlCmd);
mysql_close($con);
}
?>`发布于 2017-04-02 12:32:49
您可以使用php的SESSION变量,它存储可以在整个应用程序中访问的数据。
https://stackoverflow.com/questions/43168224
复制相似问题