goodday house, I need an assistance with this connection. i am having an issue. i created a database called squared in mysql and under it a table called register with 3 field. so i am trying to insert information through coding using php editor. but i am having undefined variable error. i have already created the forms in html.
<?php
$servername = "localhost";
$db_name="squared";
$username="root";
$password="";
//create connection
$conn = mysqli_connect($servername, $username, $password, $database);
//check connection
if (!$conn){
die("connection failed: " . mysqli_connect_error());
}
echo "connected successfully";
//use $query or sql
// name, email and address are fields of your fields; test your table. $name, $email and $address are values collected from the form
$sql = "INSERT INTO register (name, email, address) VALUES ('$name','$email' , '$address')";
if (mysqli_query($conn, $sql)){
echo "Newrecord created successfully";
}else{
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>