作者non036 (Taiwan猕猴)
看板PHP
标题[请益] php抓不到变数?
时间Thu Mar 22 16:30:56 2007
之前有人放一个压缩档,用PHP连Gmail寄信~
可是连续试了好几次,收到的信都是空白的,变数加上$_POST['']也没用
有人可以帮我抓Bug吗?
以下是表单<u4.html>
-------------------------------------------------------------
<html xmlns="
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="
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)
1F:推 shadowjohn:name 好像是保留字,用别的看看 XD 03/22 17:42
2F:→ non036:改成$user_name也是一样,试了一下~ 03/22 17:48
3F:推 shadowjohn:<input type="text" name="name" /> --> 这也要改... 03/22 17:52
4F:推 non036:有!所变数都加上"user_",一样空白信! 03/22 17:53
5F:推 kyowinner:$body内容的变数都加上单引号看看 03/22 21:07
6F:推 buganini:你不应该看信件吧...先用echo看看变数到底收到没 03/22 21:28
7F:→ buganini:如果有的话那就是gmailer的使用问题了 03/22 21:28
8F:推 non036:好!我先试试看~ 03/22 21:33
9F:推 non036:确认,变数没有撷取到,有问题? 03/22 21:36
10F:推 non036:为什麽抓不到变数 = =?谁来告诉我阿 @_@ 03/22 23:17
11F:推 KiroKu:你是不是多了个</table> 我眼睛好花@@ 03/23 00:13
12F:→ KiroKu:我找到了.. 03/23 00:15
13F:→ KiroKu:你有开magic_quote吗? 03/23 00:17
14F:推 non036:好问题!伺服器不是我架的,是学校的~!明天问问看! 03/23 00:38
15F:→ non036:因该没有多加</table>,用Dreamweaver编辑完再改的,应该没 03/23 00:39
16F:→ non036:问题才对。 03/23 00:41
17F:→ non036:Dreamweaver有DeBug功能吧!PHP用笔记簿写的,也许有Bug! 03/23 00:42
18F:推 non036:恩!magic_quote是关闭的 03/23 17:02
19F:推 windincloud:if ($gmailer->created) <= 是$gmailer->created()吗? 03/27 23:43