首页 文章

条目未出现在phpMyAdmin中

提问于
浏览
0

我已经尝试了几个小时不同的代码变体 . 我是新手 . 我似乎无法弄清楚为什么没有任何东西插入到phpMyAdmin数据库中 . 我已经验证我已连接到数据库(使用下面的echo和error函数) . 我知道mysql_正在被弃用,但请帮助brotha . 我的问题是:为什么没有插入任何内容?我正在使用PHP 4.0.10.7(Godaddy) .

<?php

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$phone_number = $_POST['phone_number'];


define('dbusername', 'someusername');
define('dbpassword', 'somepassword');
define('dbhost', 'localhost');
define('dbname', 'somedb');

if (($first_name=="")||($last_name=="")||($email=="")||($password=="")||($phone_number=="")) 
        { 
        echo "All fields are required, please fill <a href='home.html'>the form</a> again."; 
        die();
        } 

$connect = mysql_connect(dbhost,dbusername,dbpassword) or die("Could not connect. " . mysql_error());

$db = mysql_select_db(dbname, $connect);

$queryemail = "SELECT * FROM User WHERE email = '$email'";

$insertemail = "INSERT INTO User (email,password,first_name,last_name,phone_number) VALUES ('$email','$password','$first_name','$last_name','$phone_number')"; 

echo $insertemail;
mysql_close($connect);

header("Location: account_summary.html");

?>

回应$ insertemail返回

INSERT INTO User(email,password,first_name,last_name,phone_number)VALUES('asdfsda @ sdfa','','sadf','asdf','') . 密码未显示,但电话号码也没有显示 . 我正在测试的实际表格位于Desotocab.com . 谢谢!

按照要求:

<form action="login.php" method="post">
		
		<label>First Name: *</label><input type="text" name="first_name"/>
<label>Last Name: *</label><input type="text" name="last_name"/>
<label>Email: *</label><input type="email" name="email"/>
<label>Password: *</label><input type="password" name="password"/>
<sub>Password must be 8 characters minimum</sub>
<label>Phone Number: *</label><input type="text" name="phone_number"/>
<input type="submit" value="Sign Up"/> </form>

User 表架构:

专栏|类型
user_id | INT(11)
电子邮件| VARCHAR(22)
密码| VARCHAR(64)
created_on |时间戳
first_name | VARCHAR(50)
last_name | VARCHAR(50)
phone_number | VARCHAR(20)

1 回答

  • 1

    将以上代码从MySQL兼容改为MySQLi兼容

    然后使用

    $result = mysqli_query($connect, $insertemail);
    

    之前

    echo $insertemail;
    

相关问题