-1

我的表单没有提交,我的数据库插入类有效并且我已经测试过了。但我的表单似乎不想从我的表单提交或发布值。有什么我遗漏的吗?

<form name="form1" method="post" action="sub_newsletter.php" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Newsletter</td>
</tr>
<tr>
<td>Name : </td>
<td><input name="name" type="text"></td>
</tr>
<tr>
<td>Email : </td>
<td><input name="email" type="text"></td>
</tr>
<tr>
<td> <input type="text" name="check_spam" id="check_spam" size="30" style="display:none;" />  </td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="image" name="submit" src="images/sub.jpg" style="width:180px; height:70px;"></td>
</tr>
</form>
</table>

我的提交脚本

<?php
include('includes/database.php');
include('includes/settings.php');
include('includes/newsletter.php');

if (isset($_POST['submit'])){
//to check if posting
echo $username=rtrim($_POST['name']);
echo $myemail=rtrim($_POST['email']);
//
$check=$_POST['check_spam'];
if(!empty($check)){ echo "You are spam"; } else{
$username=rtrim($_POST['name']);
$myemail=rtrim($_POST['email']);
$news =  new Newsletter();
$new->first_name=$username;
$new->email=$myemail;
$new->create();
echo "<script>alert(\"Thank you for your subscription\"); </script>";
echo "<script>window.location.replace(\"index.html\"); </script>";
}
}
?>
4

1 回答 1

1

你显然错过了提交按钮

<input type="submit" name="submit">

由于您已经有一个具有该名称的字段,因此只需更改它或使用其他名称。

于 2013-03-09T18:06:43.340 回答