我正要为此扯掉我的头发。我正在构建一个测试站点,我的测试表单似乎运行良好,但是当我提交表单时,它显示“找不到页面”。这可能是愚蠢的,但我做错了什么?
这是我的代码:
<?php
if(isset($_POST['username']) && isset($_POST['password']))
{
$db =connect('jsnow_jsnow','missysnow2005');
if($db!=false)
{
register($db);
echo "User registered";
}
}
function connect($dbuser,$dbpassword)
{
try{
$db = new PDO('mysql:host=localhost;dbname=jsnow_login',$dbuser,$dbpassword);
return $db;
}catch(PDOException $e){
echo $e;
return false;}
}
function register($db)
{
$user = mysql_real_escape_string($_POST['username']);
$password = sha1($_POST['password']);
$email = mysql_real_escape_string($_POST['e_mail']);
$query = "INSERT INTO members(username,password,email) values('".$user."','".$password."','".$email."')";
try{
$db->eginTransaction();
$db->exec($query);
$db->commit();
echo "commit succesful";
}catch(Exception $e){}
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="http://localhost/jsnow_login/registration.php" method="post">
username:<input type="text" name="username"/>
password:<input type="password" name="password"/>
email<input type="text" name="e_mail"/>
<input type="submit"/>
</form>
</body>
</html>