用php做这样的事是相当简单的,不考虑安全等情况,仅作为演示:
<code class="lang-">
<?php
$form1 = '<form method="post" action="index.php?tips"><input type="text" name="your_input"><input type="submit" value="提交">';
$form2 = '<form method="post" action="index.php?show"><input type="submit" value="请点击这里"></form>';
switch($_SERVER["QUERY_STRING"])
{
case '':
echo '<script>document.write(\''.$form1.'\');</script>';
break;
case 'tips':
session_start();
$_SESSION['input'] = $_POST['your_input'];
echo '<script>document.write(\''.$form2.'\');</script>';
break;
case 'show':
session_start();
echo '<script>document.write(\''.$_SESSION['input'].'\');</script>';
break;
}
</code>