I have added database to my form, until i give an input this message keeps on displaying

Viewed 18

The error enter image description here

IF I add email and password the below error doesn't occur, but if i leave it blank the error occurs. It is showing error at if conditon "if(!conn)" .Is there any way i ca remove the error


<?php
$db_host="127.0.0.1";
$db_username="root";
$db_password="";
$db_name="phplearning";   //my database name created in xampp sql 

$conn=mysqli_connect($db_host,$db_username,$db_password,$db_name);
if(!$conn)
{
    echo "Connection failed".mysqli_connect_error();
    exit;
}
$email=$_GET['email'];
$password=$_GET['password'];

$sql="Insert into users(email,password) values('$email', '$password')";
$result=mysqli_query($conn,$sql);
if(!$result){
    echo"Error".mysqli_error($conn);
    exit;
}
echo "Registration succesful";
mysqli_close($conn);
?>

<?php

$email=$_GET['email'];
$password=$_GET['password'];
echo "Your email id is : $email.<br/>";
echo "Your password is: $password";
?>

0 Answers
Related