从我的注册表单中插入数据后,我无法将数据保存到我的数据库中。
有趣的是,只保存了两个字段。即,名字和姓氏,但是无论我多么努力地寻找解决方案,电话号码之类的东西都不是。
以下是用于将 Mysql Db 与注册表单连接的文件。
1. 注册.PHP
<html>
<head>
<title>Registration Form</title>
<style type="text/css">
h3 {
font-family: Calibri;
font-size: 22pt;
font-style: normal;
font-weight: bold;
color: SlateBlue;
text-align: center;
text-decoration: underline
}
table {
font-family: Calibri;
color: white;
font-size: 11pt;
font-style: normal;
text-align:;
background-color: SlateBlue;
border-collapse: collapse;
border: 2px solid navy
}
table.inner {
border: 0px
}
</style>
</head>
<body>
<form method="post" action="check.php" enctype="multipart/form-data">
<table width="300" border="0"
<table align="center" cellpadding="10">
<tr>
<td>FirstName:</td>
<td><input type="text" name="FirstName"></td>
</tr>
<tr>
<td>LastName:</td>
<td><input type="text" name="LastName"></td>
<tr>
<td>Phone:</td>
<td><input type="double" name="Phone"></td>
</tr>
<span style="size:10%;color:#FF0000"><?php if(isset($_GET["pass"])) { echo $_GET["pass"]; } ?></span>
<tr>
<td> </td>
<td><input type="submit" value="Submit" name="registration"/></td>
</tr>
</table>
</form>
</body>
</html>
2.检查.PHP
<?php
if (isset($_POST['registration'])) {
require "connection.php";
$FirstName = strip_tags($_POST['FirstName']);
$LastName = strip_tags($_POST['LastName']);
$DOB = strip_tags($POST['Phone']);
mysql_query("
INSERT INTO users
(FirstName, LastName, Phone)
VALUES
('$FirstName', '$LastName', '$Phone')
") or die("" . mysql_error());
echo "Successful Registration!";
}
?>
3. 连接.PHP
<?
$name = "root";
$pas = "password";
$dbname = "registration";
$con = mysql_connect("localhost:7077", $name, $pas);
mysql_select_db($dbname, $con);
?>