PHP 板


LINE

看板 PHP  RSS
<?php require_once('Connections/connection.php'); ?> <? mysql_query("set names big5"); // 启动session if (!isset($_SESSION)) { session_start(); } // 尚未登入 if (!isset($_SESSION['MM_Username'])) { // 在login_form.php档案中,登入成功後要前往那一个档案 $_SESSION['nextstep'] = 'member_info.php'; header('Location: login_form.php'); } ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "member_info_form")) { $updateSQL = sprintf("UPDATE member SET username=%s, password=%s, name=%s, sex=%s, birthday=%s, email=%s, phone=%s, address=%s, uniform=%s,WHERE id=%s", GetSQLValueString($_POST['username'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['name'], "text"), GetSQLValueString($_POST['sex'], "text"), GetSQLValueString($_POST['birthday'], "date"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['phone'], "text"), GetSQLValueString($_POST['address'], "text"), GetSQLValueString($_POST['uniform'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($updateSQL, $connection) or die(mysql_error()); mysql_query("set names big5"); $updateGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } $colname_member_info = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_member_info = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_connection, $connection); $query_member_info = sprintf("SELECT * FROM member WHERE username = '%s'", $colname_member_info); $member_info = mysql_query($query_member_info, $connection) or die(mysql_error()); $row_member_info = mysql_fetch_assoc($member_info); $totalRows_member_info = mysql_num_rows($member_info); ?> <!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=big5" /> <title>基本资料</title> <link href="CSS/all.css" rel="stylesheet" type="text/css" /> <link href="CSS/member_info.css" rel="stylesheet" type="text/css" /> <script type="text/JavaScript"> <!-- function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } //--> </script> </head> <body> <table class="all_style1"> <tr> <td align="left" valign="top" class="all_style2"> <table align="center" class="member_info_style1"> <tr> <td align="left" valign="middle" class="member_info_style2"><span class="member_info_style3">基本资料</span></td> </tr> <tr> <td align="left" valign="top" class="member_info_style4"> <table> <tr> <td> <form action="<?php echo $editFormAction; ?>" id="member_info_form" name="member_info_form" method="POST"> <table class="member_info_style5"> <tr> <td colspan="2" align="left" valign="top" class="member_info_style6"> <strong> 注意事项:</strong> <ol> <li>在修改之前,请先确认您要修改的资料。<br /></li> <li>修改资料之後,就无法再还原。</li></ol><hr class="member_info_style10" /> </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"><span class="member_info_style11">帐  号 </span> </td> <td class="member_info_style4"> <input name="username" type="text" class="member_info_style8" id="username" onblur=" if (this.value.search(/[\u4E00-\u9FA5]/g) != -1) { alert('[帐号] 栏位不可以是中文!'); this.value = ''; this.focus(); }" value="<?php echo $row_member_info['username']; ?>" size="20" maxlength="12" /> (4~10个字元,请勿使用中文) </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">密  码</span></td> <td class="member_info_style4"> <input name="password" type="text" class="member_info_style8" id="password" onblur=" if (this.value.search(/[\W]/g) != -1) { alert('[密码] 栏位必须是英文字母与数字!'); this.value = ''; this.focus(); }" value="<?php echo $row_member_info['password']; ?>" size="20" maxlength="12" /> (4~10个字元,请勿使用中文) </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">姓  名</span> </td> <td class="member_info_style4"> <input name="name" type="text" class="member_info_style8" id="name" value="<?php echo $row_member_info['name']; ?>" size="20" /> </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"><span class="member_info_style11">昵  称</span> </td> <td class="member_info_style4"><input name="uniform" type="text" class="member_info_style8" id="uniform" value="<?php echo $row_member_info['uniform']; ?>" size="40" /> </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">性  别</span> </td> <td class="member_info_style4"> <input <?php if (!(strcmp($row_member_info['sex'],"男"))) {echo "checked=\"checked\"";} ?> name="sex" type="radio" value="男" /> &nbsp;男&nbsp; <input <?php if (!(strcmp($row_member_info['sex'],"女"))) {echo "checked=\"checked\"";} ?> name="sex" type="radio" value="女" /> &nbsp;女 </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">电子信箱</span> </td> <td class="member_info_style4"> <input name="email" type="text" class="member_info_style8" id="email" onblur=" if (this.value.search(/^\w+((\.\w+)|(-\w+))*@\w+((\.|-)\w+)*\.\w+$/) == -1) { alert('[电子信箱] 栏位的格式不正确!'); this.value = ''; this.focus(); }" value="<?php echo $row_member_info['email']; ?>" size="40" /> </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">出生日期</span> </td> <td class="member_info_style4"> <input name="birthday" type="text" class="member_info_style8" id="birthday" value="<?php echo $row_member_info['birthday']; ?>" size="20" /> (请填入西元年, 例如 1991-1-1) </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">连络电话</span> </td> <td class="member_info_style4"> <input name="phone" type="text" class="member_info_style8" id="phone" value="<?php echo $row_member_info['phone']; ?>" size="20" /> </td> </tr> <tr> <td align="center" valign="middle" class="member_info_style7"> <span class="member_info_style11">地  址</span> </td> <td class="member_info_style4"> <input name="address" type="text" class="member_info_style8" id="address" value="<?php echo $row_member_info['address']; ?>" size="50" /> </td> </tr> <tr> <td colspan="2" class="member_info_style9"> <hr class="member_info_style10" /> <input name="member_info_submit" type="submit" id="member_info_submit" value="确定送出" onclick=" var fieldvalue = document.member_info_form.username.value; if (fieldvalue == '') { alert('[帐号] 栏位不可以是空白!'); document.member_info_form.username.focus(); return false; } else if (fieldvalue.length < 4 || fieldvalue.length > 10) { alert('[帐号] 栏位的长度必须是4~10个字元!'); document.member_info_form.username.focus(); return false; } fieldvalue = document.member_info_form.password.value; if (fieldvalue == '') { alert('[密码] 栏位不可以是空白!'); document.member_info_form.password.focus(); return false; } else if (fieldvalue.length < 4 || fieldvalue.length > 10) { alert('[密码] 栏位的长度必须是4~10个字元!'); document.member_info_form.password.focus(); return false; } fieldvalue = document.member_info_form.name.value; if (fieldvalue == '') { alert('[姓名] 栏位不可以是空白!'); document.member_info_form.name.focus(); return false; } fieldvalue = document.member_info_form.uniform.value; if (fieldvalue == '') { alert('[昵称] 栏位不可以是空白!'); document.member_info_form.uniform.focus(); return false; } fieldvalue = document.member_info_form.email.value; if (fieldvalue == '') { alert('[电子信箱] 栏位不可以是空白!'); document.member_info_form.email.focus(); return false; } fieldvalue = document.member_info_form.phone.value; if (fieldvalue == '') { alert('[连络电话] 栏位不可以是空白!'); document.member_info_form.phone.focus(); return false; } fieldvalue = document.member_info_form.address.value; if (fieldvalue == '') { alert('[地址] 栏位不可以是空白!'); document.member_info_form.address.focus(); return false; }" /> <input name="member_info_cancel" type="button" id="member_info_cancel" onclick="MM_goToURL('parent','index.php');return document.MM_returnValue" value="取消" /> <hr class="member_info_style10" /> </td> </tr> </table> <input name="id" type="hidden" id="id" value="<?php echo $row_member_info['id']; ?>" /> <input type="hidden" name="MM_update" value="member_info_form"> </form> </td> </tr> </table> </td> </tr> </table> </body> </html> <?php mysql_free_result($member_info); ?> 抱歉ˊˋ SQL就差不多是这些了...我是新手..都拿工具书参考着改 还请各位大大赐教... --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.133.71.108
1F:→ knockout:基本上 ... 程式码POST出来 不告诉人有啥错误讯息的 .. 07/18 22:56
2F:→ knockout:是没啥人要看的 .... 07/18 22:57
3F:→ p3013220132:上一篇有写错误讯息- - 是他们说没程式..我才po的 07/18 22:58
4F:推 hivabe:这个叫原始码不叫sql 07/18 22:59
5F:→ hivabe:uniform=%s,WHERE id=%s" <- `我猜where前多了逗号? 07/18 23:00
6F:推 p3013220132:抱歉ˊˋ 我是新手...我不知道这些原始码里面错在哪. 07/18 23:01
7F:→ p3013220132:我试试...还是hivabe大大愿意帮我 msn聊聊ˊˋ 07/18 23:02
8F:→ p3013220132:我是个可怜没人教的小新手- - 07/18 23:03
9F:推 knockout:嗯 没看到前文 抱歉 07/18 23:03
10F:→ knockout:错误是在於 字串做搜寻时 要加引号 07/18 23:03
11F:推 p3013220132:哪一段呢- - 07/18 23:04
12F:→ knockout:例如: username='%s' 07/18 23:04
13F:推 knockout:不过 ... 这是PHP版 =_= (倒) 07/18 23:06
14F:推 p3013220132:都不是耶....谁还知道错在哪.... 07/19 10:07
15F:→ alexblue:是DW产生的code 建议基本功学紮实点.不然问题问不完XD뀠 07/19 12:21
16F:推 yanli2:end+1 .. 07/19 15:25
17F:→ yanli2:懒的看第一行什麽都没讲直接po code的文章 07/19 15:26
18F:推 yanli2:Sorry 看错原来这篇是回覆 有第一篇 收回我刚推的.抱歉 07/19 15:30
19F:推 p3013220132:就是那个逗点..之前我错了ˊˋ 谢谢hivabe 07/19 19:29
20F:→ p3013220132:真专业^^" hivabe大大 07/19 19:30







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP