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燈, 水草

請輸入看板名稱,例如:BuyTogether站內搜尋

TOP