简体   繁体   中英

the data from my web form is not entering into my msql database

I created a web form that should enter my the info from the form into the database. In my form I have three fields name email and phonenumber, when the user enters the data into the form and hits the submit button the name,email and phone number that the user entered should go into the my mysql database in a table called Users. But when I check the users table in my mysql database after filling out the form and hitting the submit button the Users table in my mysql database is empty.

here is the code for the web form where the user enters the user name and email

<!DOCTYPE HTML>
<html>  
<body>



<form action="signup.inc.php" method="post">
Name: <input type="text" name="lname"><br>
E-mail: <input type="text" name="email"><br>
Phone Number: <input type="text" name="phone"><br>
<input type="submit">
</form>




</body>
</html>

Here is the code for handles my how the data will enter the Mysql database

<?php

include_once 'dbconnection.php';

$nName= $_POST['lname'];
$eEmail=$_POST['email'];
$phoneNumber= $_POST['phone'];
$sql= "INSERT INTO Users (lastname,email,phone_number) VALUES ('$nName','$eEmail','$phoneNumber');";

mysqli_query($conn,$sql);
header("Location:LoginConnection.php");

?>

Here is the code that connects to my database (the code that actually authenticates with mysql) Note: I chose not to put the actual password in this post but i do put the actual password in the code


<?php
$dbServername= "localhost";
$dbUsername = "root";
$dbpassword = "";
$dbName = "new_schema";
$conn= mysqli_connect($dbServername,$dbUsername,$dbpassword,$dbName);


?>

There are two possible mistakes:

1.check the connection, as mentioned above.

2.check the table name and column Name are the same in database or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM