[請益] 抓不到臭蟲(網頁範例練習)

看板PHP作者 (從心開始)時間18年前 (2007/03/16 23:39), 編輯推噓4(401)
留言5則, 2人參與, 最新討論串1/1
這個檔案在跑的時候 他一直說我有語法錯誤 Parse error: syntax error, unexpected '}' in C:\wamp\www\test0314\login.php on line 19 可是明明左右都有對到大跨弧{}卻仍然跑出來有問題呢 煩請板上的眾強者幫忙小弟解答一下疑惑 原始網頁出處 http://php.igt.com.tw/unit_115.htm 檔案如下 login.php <?php if(isset($_POST[Submit])){ // 如果帳號和密碼正確的話,寫入Session變數,並視情況重導到相關 的頁面 if($_POST[account] == "admin" && $_POST[password] == "pass"){ // 啟動 Session session_start(); // 登記 Session 變數名稱 session_register('authenticated'); session_register('fruits'); session_register('login_time'); // 寫入 Session 變數值 $_SESSION['authenticated'] = true; $_SESSION['fruits'] = array("orange", "banana", "apple"); $_SESSION['login_time'] = date('Y-m-d h:i:s'); // 檢查在 $_SESSION 全域變數中,是否有之前設定好的網址重導 Session 變數 if(isset($_SESSION[UrlRedirect])) {$redir = $_SESSION[UrlRedirect]} else{$redir = 'login_success.php';} // 重導到相關頁面 header("Location: $redir"); exit; }else{ header('Location: access_denied.htm'); exit; } } ?> <html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=big5" /></head> <body> <form name="form1" id="form1" method="post" action=""> <p align="center">帳號: <input name="account" type="text" id="account" /> </p> <p align="center">密碼: <input name="password" type="password" id="password" /> </p> <p align="center"> <input type="submit" name="Submit" value="登 入" /> </p> </form> </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.251.219

03/16 23:41, , 1F
{$redir = $_SESSION[UrlRedirect]} 少了;
03/16 23:41, 1F

03/16 23:45, , 2F
我還是不太清楚耶 能否您再提醒一下呢~~謝謝你
03/16 23:45, 2F

03/16 23:48, , 3F
{$redir = $_SESSION[UrlRedirect];}
03/16 23:48, 3F

03/16 23:57, , 4F
Parse error: syntax error, unexpected $end
03/16 23:57, 4F

03/16 23:59, , 5F
這網頁給的原始碼還挺多錯的 感謝這位大大的幫忙~~
03/16 23:59, 5F
文章代碼(AID): #15-heerp (PHP)
文章代碼(AID): #15-heerp (PHP)