【发布时间】:2015-10-31 14:50:25
【问题描述】:
您好,我在将表单信息插入数据库时遇到了一些问题。 我正在接收连接到数据库的回显,但是当单击提交时,我收到 404 错误。 任何帮助将不胜感激。提前谢谢!
<?php
$host="localhost";
$dbuser="root";
$pass="******";
$dbname="learn";
$con = mysqli_connect ($host, $dbuser, $pass, $dbname);
if (mysqli_connect_errno ())
{
die ("Connection Failed!" . mysqli_connect_error());
}
else
{
echo "Connected to database {$dbname} ";
}
if(isset($_POST['submit']))
{
$fname=$_POST ['fname'];
$lname=$_POST ['lname'];
$email=$_POST ['email'];
$pswrd=$_POST ['pswrd'];
$sql = $con->query ("INSERT INTO users ( fname, lname, email, pswrd,)
VALUES ( ' {$fname} ' , ' {$lname} ' , ' {$email} ' , ' {$pswrd} ' , ')" );
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Signup</title>
<meta charset="utf-8">
<meta name="description" content="description of webpage">
<meta name="keywords" content="keywords go here">
<meta name="author" content="me">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/signup.css">
<link rel="index" href="index.php">
<link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>
<div class="header">
<div id="logo">
<a href="index.php"><img src="img/logo.png" alt="logo" title="learnlogo"/></a>
</div>
</div>
<div id="signupform">
<form action="submit" method="post"><br>
<input type="text" name="fname" placeholder="First name">
<input type="text" name="lname" placeholder="Last name"><br><br>
<input type="text" name="email" placeholder="Email address">
<input type="password" name="pswrd" placeholder="Password"><br><br>
<input type"submit" value="Submit">
</form>
</div>
<?php
include ("inc/footer.php");
?>
【问题讨论】:
-
action="submit"需要是处理action="thisform.php"等表单的url -
对不起,你能给我一个例子吗?我是新手。我将所有代码都放在 1 页上,所以我会将其设为 action="signup.php" 吗?
-