日期:2014-05-17 浏览次数:20499 次
1. 表单页面 <form method="get" action="myphp.php" name="form1"> <br> <div id="divname"> 名字<input name="name" type="text" id="username" value="名字" onBlur="showAgeText();" /> </div> <div id="divage" style="display: none;"> 岁数<input name="age" type="text" id="age" value="" /> </div> <input name="submit" type="submit" id="submitbutton" value="查询" /> </form> <script type="text/javascript"> <!-- function showAgeText() { var agediv = document.getElementById('divage'); agediv.style.display=""; } //--> </script> 2.接受页面 myphp.php <?php if (isset ( $_GET ['name'] ) && isset ( $_GET ['age'] )) { $Name = $_GET ['name']; $Age = $_GET ['age']; // 插入数据库 //链接数据库部分自己写了 $SQL = "INSERT INTO xxx (`name`,`age`) VALUE ('{$Name}','{$Age}')"; mysql_query ( $SQL ); if (mysql_affected_rows () > 0) { echo '插入成功!'; } } ?>