我想提交一个表单,并按下提交按钮后,我想第二个窗体出现,同时仍然持有值(我有这部分工作) 。我被告知使用isset
函数,但我无法使它工作。代码工作正常(我没有复制PHP的东西)。按提交后,我想它显示第二个表格
<!DOCTYPE html>
<html>
<head>
<title>Prac 2 Task 12</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" id="custinfo" >
<table>
<tr>
<td><label for="customerid">Customer ID (integer value): </label></td>
<td>
<input
type="text"
id="customerid"
name="customerid"
size="10"
value="<?php
echo isset($_POST['customerid'])
? htmlspecialchars($_POST['customerid'])
: ''; ?>"
/>
<?php echo $customerIDError ?>
</td>
<td style="color:red"></td>
</tr>
</table>
<p>
<input type="submit" name = "submit" value="Save Data"/>
<input type="reset" value="Reset Form" />
</p>
</form>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" id="custinfo" >
<table>
<tr>
<td><label for="username">Username: </label></td>
<td>
<input
type="text"
id="username"
name="username"
size="10"
value="<?php
echo isset($_POST['username'])
? htmlspecialchars($_POST['customerid'])
: ''; ?>"
/>
<?php echo $customerIDError ?></td>
<td style="color:red"></td>
</tr>
</table>
<p>
<input type="submit" name = "submit" value="Save Data"/>
<input type="reset" value="Reset Form" />
</p>
</form>
</body>
</html>
你到现在为止尝试过什么? –
HTML内的'id's'必须是'unique'。 –
你在这里有什么问题?你声称你自己有“这部分解决了”。事实上,除了一些小故障外,你将能够解决你自己。 – arkascha