<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>新增用户</title> </head> <body> <form action="addDo.php" method="post"> <input type="hidden" value=" "/> <table> <tr> <td>用户名 </td> <td> <input type="text" size="10" /></td> </tr> <tr> <td>密码</td> <td> <input type="password" size="10" /></td> </tr> <tr> <td>性别</td> <td> <input type="radio" value="男" checked="checked" /> 男<input type="radio" value="女" /> 女 </td> </tr> <tr> <td>年龄</td> <td> <input type="text" size="3" /></td> </tr> <tr> <td>出生年月</td> <td> <select> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> </select> 年 <select> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> 月 <select> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> 日 </td> </tr> <tr> <td>爱好</td> <td> <input type="text" size="44" /></td> </tr> <tr> <td>个人简介</td> <td> <textarea rows="10" cols="30"></textarea></td> </tr> <tr> <td colspan="2"><input type="submit" value="增加用户" /></td> </tr> </table> <p> </p> <p> </p> <p> </p> </form> </body> </html>
addDo.php
<?php require_once 'inc/dbConn.php'; //////////////////// ///获取用户信息 //////////////////// $user_id = $_POST['user_id']; $user_name = $_POST['user_name']; echo $user_name; $password= $_POST['password']; if($_POST['sex']=='男') { $sex=1; } else if($_POST['sex']=='女') { $sex=2; } else $sex=3; ; $age = $_POST['age']; $birthday_y = $_POST['birthday_y']; $birthday_m = $_POST['birthday_m']; $birthday_d = $_POST['birthday_d']; $birthday=mktime(0,0,0,$birthday_m,$birthday_d,$birthday_y); $hobby = $_POST['hobby']; $profile = $_POST['profile']; $addTime=mktime(date("h"),date("m"),date("s"),date("m"),date("d"),date("Y")); $lastLoginTime=$addTime; $sql = "insert into user (username,password,sex,age,birthday,hobby,profile,add_time,last_login) ". "values('$user_name','$password','$sex','$age','$birthday','$hobby','$profile','$addTime','$lastLoginTime')"; echo $sql; // 执行sql语句 mysql_query($sql,$con); // 获取影响的行数 $rows = mysql_affected_rows(); // 返回影响行数 // 如果影响行数>=1,则判断添加成功,否则失败 if($rows >= 1){ alert("添加成功"); href("https://www.jb51.net/userListt.php"); }else{ alert("添加失败"); // href("https://www.jb51.net/addUser.php"); } function alert($title){ echo "<script type='text/javascript'>alert('$title');</script>"; } function href($url){ echo "<script type='text/javascript'>window.location.href='$url'</script>"; } ?>
您可能感兴趣的文章: