Warning: mysqli_fetch_array() expects parameter 1 to be
mysqli_result, null given in C:\wamp64\www\login1\save.php on line 9
Warning: mysqli_query() expects at least 2 parameters, 1 given in
C:\wamp64\www\login1\save.php on line 8
I am clearly new to php and sql. I tried writing a code for a simple login page.
Save.php:
<?php
$conn=mysqli_connect('localhost','','');
if($conn)
{
mysqli_select_db($conn,"studentdb");
$query="select * from user";
$result=mysqli_query($query);
while( $row=mysqli_fetch_array($result) )
{
echo "<br><br> *******USER DATA*********";
echo "<br> Name : $row[name]";
echo "<br> Username : $row[username] ";
echo "<br> Password : $row[password] ";
}
}
mysqli_close($conn);
?>
Next page after login:
<?php
$name=$_GET['name'];
$username=$_GET['uname'];
$password=$_GET['pwd'];
echo "<h3> Welcome $name...!</h3>";
$conn=mysql_connect('localhost','root','');
if($conn)
{
mysql_select_db("studentdb",$conn);
$query="insert into user values ('$name', '$username', '$password')";
mysql_query($query);
echo "Your Login Registration is successful !!!!";
}
mysql_close($conn);
?>
This is what I have written. I am getting the above mentioned error while give required information in name, username and password.