这是index.php:
header('Location:media.php?module=home'); 我称其为media.php:
<html>
<head>
<title>Test media</title>
</head>
<body>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><img src="images/cms/header.png" width="780" height="77"></td>
</tr>
<tr>
<td width="200" valign="top" bgcolor="#1e2528">
<?php include "menu.php"; ?>
<p align="center"> </p>
</td>
<td width="760" valign="top" bgcolor="#FFFFFF">
<p>
<?php include "content.php"; ?>
<br>
</p>
</td>
</tr>
</table>
</body>
</html>这就是问题,content.php:
<table width="100%" cellspacing=5>
<?php
include_once 'include/config.php';
include_once 'admin/include/date_lib.php';
include_once 'class/class_lib.php';
include_once 'class/paging.php';
$action = new DB();
$action->db_connect();
if ($_GET[module]=='home'){
</td></tr>";
echo "<tr><td align=center>Headline News<br><br></td></tr>";
elseif ($_GET[module]=='request'){
echo "<tr><td class=judul_head>» Hubungi Kami</td></tr>";
echo "<tr><td class=isi>Silahkan hubungi kami secara online:</td></tr>";
echo "<form action='?module=sendemail' method='post'>
<tr><td class=isi>Name : <input type=text name=name size=35></td></tr>
<tr><td class=isi>E-mail : <input type=text name=email size=35></td></tr>
<tr><td class=isi>Subject: <input type=text name=subject size=50></td></tr>
<tr><td class=isi>Message : <br><textarea name=message rows=13 cols=70>
</textarea></td></tr>
<tr><td><input type=submit value=Send></td></tr>
</form>";
echo "<tr><td class=back><br>
[ <a href=javascript:history.go(-1)>Back</a> ]</td></tr>";
}
elseif ($_GET[module]=='sendemail'){
mysql_query("INSERT INTO email(name,
email,
subject,
message,
date)
VALUES('$_GET[name]',
'$_GET[email]',
'$_GET[subject]',
'$_GET[message]',
'$today_date')");
echo "<tr><td class=header_head>» Status Email</td></tr>
<tr><td class=isi>Email has been sent</td></tr>
<tr><td class=back><br>
[ <a href=index.php>Back</a> ]</td></tr>";
}我有一个使用post方法的电子邮件表单。但是当我点击提交按钮的时候,它会像这样出现在url地址栏上
http://staging/media.php?name=Test+name&email=Test+email&subject=test+subject&,message=Test+message就像我使用get方法时一样。但是如果在查询中将$_POST更改为$_GET。它不起作用。
我的脚本中有什么遗漏了吗?或者是因为我使用$_GET[module]方法在同一页面上调用?
发布于 2012-05-01 15:13:48
if ($_GET[module]=='home'){ </td></tr>";在我看来你遗漏了echo "语句。
发布于 2012-05-01 15:15:07
由于您已经选择将表单方法设置为'post',因此您从mysql_query中的表单获得的值应该是$_POST而不是$_GET。希望这能有所帮助!
发布于 2012-05-01 15:17:14
您还遗漏了elseif ($_GET[module]=='request')前面的括号。我建议您使用语法突出显示编辑器。很容易就能找到这些东西。
将HTML输出和脚本混合在一起也不好。
https://stackoverflow.com/questions/10394560
复制相似问题