<?php
include('connect.php');
if (isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
global $mysqli;
$query = ("INSERT INTO lr (username, password, email) VALUES ('$username', '$password', '$email')");
$result = $mysqli->query($query, $connection) or die(mysql_erorr());
if($result === true){
$msg = "User Created Successfully.";
}
}
?>
目录:
<form id="RegisterUserForm" action="" method="post" enctype="multipart/form-data">
<fieldset>
<p>
<label for="name">Name</label>
<input id="name" name="name" type="text" class="text" value="" />
</p>
<p>
<label for="tel">Email</label>
<input id="email" name="email" type="email" value="" />
</p>
<p>
<label for="Username">Username</label>
<input id="username" name="username" type="username" value="" />
</p>
<p>
<label for="email">Password</label>
<input id="password" type="password" name="password" class="text" value="" />
</p>
<p>
<label for="Cpassword">Confirm Password</label>
<input id="Cpassword" name="Cpassword" class="text" type="password" />
</p>
<p>
<label for="acceptTerms">
I agree to the <a href="">Terms and Conditions</a> and <a href="">Privacy Policy</a><br/>
<input id="acceptTerms" name="acceptTerms" type="checkbox" />
</label>
</p>
<p>
Upload a picture of your student ID. This is for your own safety from fraud attempts
<input type="file" name="fileToUpload" id="fileToUpload" style="color:green">
<input type="submit" value="Upload Image" name="submit" style="color:green">
<br/><br/><br/>
</p>
<input type="submit" id="registerNew" value="Register" />
</fieldset>
ad
</form>
这是我的代码,当我单击注册按钮时,它给了我这个错误
" 致命错误:在第 112 行的 C:''wamp''www''Unnamed Site 2''Signup.php 中对非对象调用成员函数 query() "
我仍然是这个PHP东西的新手,需要帮助
!!同样,当我尝试通过DREAMWEAVER连接我的DATBASE时,它给了我一个ERROY说没有DTATABASES ABAILABE的ERROY
提前致谢
调用成员函数 query() 意味着您正在尝试使用一个名为 query 的函数,该函数不作为 PHP 或用户定义的函数存在。
你的变量$query周围不应该有 ( )。用于调用函数。
只需使用 $query = "您的 sql 查询";
$query = "INSERT INTO lr (username, password, email) VALUES ('$username', '$password', '$email')";
而且您不应该依赖用户输入。在使用 $_POST 变量之前,您已经创建了它们的新变量,这很好,但您应该准备好将它们发送到您的数据库中。
查看如何防止 php 中的 sql 注入