//查询数据库 $verify_sql = "SELECT * FROM `user` WHERE `mail` = '" . $mail . "' AND `password` = '" . $pass_md5 . "'"; $result = mysql_query($verify_sql, $conn); $success = mysql_num_rows($result); //返回结果 if ($success) { while ($row = mysql_fetch_array($result)) { /*修改最后登录时间*/ updateLoginDate($row["user_id"], $conn); /*写Cookie*/ $userIdAdmin = $row["user_id"] . $row["admin"]; setcookie("userCode", encodeCookie($userIdAdmin) . $userIdAdmin, time() + 3600, "/"); setcookie("userMail", $row["mail"], time() + 3600, "/"); setcookie("userName", $row["name"], time() + 3600, "/"); /*跳转*/ jumpToUrl("home/"); } } else { //提示登陆失败 echo "<script language='javascript' type='text/javascript'>"; echo "\$('#js_login_error_info').removeClass('f-dn')"; echo "</script>"; } } ?> </body> <!-- Author: Baoxu Date: 13-4-1 Time: 上午9:40
<?php /** * User: Baoxu * Date: 13-4-10 * Time: 上午11:10 * 更新用户的基本信息 */ /*引入主文件*/ include "../common/conn.php"; include "../common/function.php"; //从Cookie中获取UserId $userId = getDataFromCookie("id", $_COOKIE["userCode"]); //从POST中获取用户名称,用户手机号,用户签名 $updateInfo = array("name" => $_POST["name"], "phone" => $_POST["phone"], "sign" => $_POST["sign"]); if (updateUserBasicInfo($userId, $updateInfo, $conn)) { /*写入数据库成功则跳转*/ jumpToUrl("../user/"); } else { echo "未更新数据..."; jumpToUrl("../user/"); }
<?php /** * User: Baoxu * Date: 13-4-2 * Time: 下午3:50 */ include "../common/conn.php"; echo "正在处理..."; $fileType = strrchr($_POST["image"], "."); $picDir = "../book/book_img/"; //用ISBN号做图片文件名 $picName = $_POST["isbn13"] . $fileType; $picUrl = $picDir . $picName; $src = file_get_contents($_POST["image"]); $des = fopen($picUrl, "w"); fwrite($des, $src); $saveBookSql = "INSERT INTO `book` (`book_id`, `isbn10`, `isbn13`, `title`, `subtitle`, `origin_title`, `pubdate`, `author`, `translator`, `publisher`, `image`, `summary`, `pages`, `tags`, `provider`, `count`, `status`) VALUES (NULL, '" . $_POST["isbn10"] . "', '" . $_POST["isbn13"] . "', '" . $_POST["title"] . "', '" . $_POST["subtitle"] . "', '" . $_POST["origin_title"] . "', '" . $_POST["pubdate"] . "', '" . $_POST["author"] . "', '" . $_POST["translator"] . "', '" . $_POST["publisher"] . "', '" . $picName . "', '" . $_POST["summary"] . "', '" . $_POST["pages"] . "', '" . $_POST["tags"] . "', '" . $_POST["provider"] . "', '" . $_POST["count"] . "', '1')"; $result = mysql_query($saveBookSql, $conn); if (!$result) { die('Error: ' . mysql_error()); } else { jumpToUrl("success.php"); }