我在目录中唯一一个通过cPanel受密码保护的页面上有一个表单。比如...
www.site.com/directory/subdirectory/form.php
每20次提交表格(在同一会话中),我被重定向到:
www.site.com
显然,php表单处理不会发生。
发生了什么?
我已在cpanel中检查了我的重定向,但未设置任何重定向。所以我甚至不知道为什么它会进入索引页面!
NOTES 没有问题SO提到这个问题,我发现没有什么适合谷歌。我不确定问题是什么,所以很难'google'。
这是form.php格式
<?php
header('Content-Type: text/html; charset=utf-8');
session_start();
require 'functions.php';
connect();
/*“Æ” because UTF-8 encoding without BOM looks like ANSI*/
if(isset($_POST['newJob'])){
$jTDjobToDo = $_POST['jobToDo'];
$jTDwhenInfo = $_POST['whenInfo'];
$jTDwhenInfo = $jTDwhenInfo+ time();
$jTDinsertNewJob = $conn ->prepare ("INSERT INTO jobstodo (jobToDo,whenInfo) VALUES(:jobToDo,:whenInfo)");
$jTDinsertNewJob->bindParam(':jobToDo', $jTDjobToDo, PDO::PARAM_STR);
$jTDinsertNewJob->bindParam(':whenInfo', $jTDwhenInfo, PDO::PARAM_INT);
$jTDinsertNewJob->execute();
echo "New job added!<br/>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>My page</title>
<LINK href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="newjobform">
ADD A NEW JOB
<form action="http://www.site.com/myPage.php" method="POST">
New Job To Do <input type="text" name="jobToDo" id="newJobToDo" ><br/>
When to do<br/>
<input type="radio" name="whenInfo" value="0" CHECKED>Now /
<input type="radio" name="whenInfo" value="86400"> 1 day
/ <input type="radio" name="whenInfo" value="172800"> 2 days
/ <input type="radio" name="whenInfo" value="345600">4 days<br/>
<input type="radio" name="whenInfo" value="604800">7 days
/ <input type="radio" name="whenInfo" value="1209600">14 days
/ <input type="radio" name="whenInfo" value="2073600">24 days
/ <input type="radio" name="whenInfo" value="3888000">45 days<br/>
<input type="submit" value="ADD" name="newJob"><br/>
</form>
</div>
</body>
</html>
php函数连接如此..
try {
$conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
//echo 'Connected to database';
}
catch(PDOException $e) {
echo $e->getMessage();
}
}