[請益] php抓不到變數?

看板PHP作者 (Taiwan獼猴)時間18年前 (2007/03/22 16:31), 編輯推噓12(1207)
留言19則, 6人參與, 最新討論串1/1
之前有人放一個壓縮檔,用PHP連Gmail寄信~ 可是連續試了好幾次,收到的信都是空白的,變數加上$_POST['']也沒用 有人可以幫我抓Bug嗎? 以下是表單<u4.html> ------------------------------------------------------------- <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <!-- DW6 --> <head> <!-- Copyright 2005 Macromedia, Inc. All rights reserved. --> <title>報名系統</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body bgcolor="#C0DFFD"><center> <form action="mail.php" method="post" name="mail"> <table border="0"> <tr> <td><table border="1" bordercolor="#999999"> <tr> <td><div align="center"><span class="style12">姓名</span></div></td> <td><input type="text" name="name" /></td> </tr> <tr> <td><div align="center"><span class="style12">服務單位</span></div></td> <td><input type="text" name="job" /></td> </tr> <tr> <td><div align="center"><span class="style12">職稱</span></div></td> <td><input type="text" name="title" /></td> </tr> <tr> <td><div align="center"><span class="style12">餐點</span></div></td> <td><input name="food" type="radio" value="葷" /> <span class="style8">葷</span> <input name="food" type="radio" value="素" /> <span class="style8">素</span></td> </tr> </table> <p align="center"> <input type="submit" name="Submit" value="送出" /> <input type="reset" name="Reset" value="清除" /> </p></td> </tr> </table> </form></center> </body> </html> ----------------------------------------------------------------- 以下是<mail.php> ----------------------------------------------------------------- <? require("libgmailer.php"); $gmail_acc = "@gmail.com"; $gmail_pwd = "XXX"; $my_timezone = "GMT +08:00"; $gmailer = new GMailer(); if ($gmailer->created) { $gmailer->setLoginInfo($gmail_acc, $gmail_pwd, $my_timezone); // $gmailer->setProxy("proxy.company.com"); if ($gmailer->connect()) { // GMailer connected to Gmail successfully. // Do something with it. $to = "@gmail.com"; $subj = "報名表"; $name=$_POST['name']; ←有試過雙引號,還是沒抓到變數 $job=$_POST['job']; $title=$_POST['title']; $food=$_POST['food']; $body ="姓名:$name \n 服務單位:$job \n 職稱:$title \n 餐點:$food \n"; $gmailer->send($to, $subj, $body, $cc="", $bcc="", $mid="", $tid="", $files=0, $draft=false, $orig_df="", $is_html=0, $from="", $attachments = array()); } else { die("Fail to connect because: ".$gmailer->lastActionStatus()."\n"); } } else { die("Failed to create GMailer because: ".$gmailer->lastActionStatus()."\n"); } ?> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <title>傳送完畢</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </style> </head> <body bgcolor="#C0DFFD" class="pageName"> 感謝您花時間填寫資料… </body> </html> -------------------------------------------------------------------------- -- ─┬─┬─████◣ ┌─┬─┬┬─┬─╭────────────╮██ ┴┬ ┴┬ ├─ ◢██◣┴┬你偷吃, 鄭先生有看到。 ─┴ ┬┴◢◤□︵□ ├┬ ╰────────────╯◢◤ ─┬ ┴┬ □︵□┬┴┬┴┬┴┬─┬┴┬ made by ┴┬─┬┴ ├┬┴ )◤▅┴┬┴┬┴┬┴┬┴┬┴ orz ┴┬┴┬┴┬◢◤ ├┴┬ ◣◤┬┴─┴┬┴─┴┬┴┬ ⊙Ptt ◢◤ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.141.7.241 ※ 編輯: non036 來自: 220.141.7.241 (03/22 16:32)

03/22 17:42, , 1F
name 好像是保留字,用別的看看 XD
03/22 17:42, 1F

03/22 17:48, , 2F
改成$user_name也是一樣,試了一下~
03/22 17:48, 2F

03/22 17:52, , 3F
<input type="text" name="name" /> --> 這也要改...
03/22 17:52, 3F

03/22 17:53, , 4F
有!所變數都加上"user_",一樣空白信!
03/22 17:53, 4F

03/22 21:07, , 5F
$body內容的變數都加上單引號看看
03/22 21:07, 5F

03/22 21:28, , 6F
你不應該看信件吧...先用echo看看變數到底收到沒
03/22 21:28, 6F

03/22 21:28, , 7F
如果有的話那就是gmailer的使用問題了
03/22 21:28, 7F

03/22 21:33, , 8F
好!我先試試看~
03/22 21:33, 8F

03/22 21:36, , 9F
確認,變數沒有擷取到,有問題?
03/22 21:36, 9F

03/22 23:17, , 10F
為什麼抓不到變數 = =?誰來告訴我阿 @_@
03/22 23:17, 10F

03/23 00:13, , 11F
你是不是多了個</table> 我眼睛好花@@
03/23 00:13, 11F

03/23 00:15, , 12F
我找到了..
03/23 00:15, 12F

03/23 00:17, , 13F
你有開magic_quote嗎?
03/23 00:17, 13F

03/23 00:38, , 14F
好問題!伺服器不是我架的,是學校的~!明天問問看!
03/23 00:38, 14F

03/23 00:39, , 15F
因該沒有多加</table>,用Dreamweaver編輯完再改的,應該沒
03/23 00:39, 15F

03/23 00:41, , 16F
問題才對。
03/23 00:41, 16F

03/23 00:42, , 17F
Dreamweaver有DeBug功能吧!PHP用筆記簿寫的,也許有Bug!
03/23 00:42, 17F

03/23 17:02, , 18F
恩!magic_quote是關閉的
03/23 17:02, 18F

03/27 23:43, , 19F
if ($gmailer->created) <= 是$gmailer->created()嗎?
03/27 23:43, 19F
文章代碼(AID): #160Zx61O (PHP)
文章代碼(AID): #160Zx61O (PHP)