<?php
$servername = "localhost";
$username = "root";
$password = "vish";
$database = "android";
$conn= new mysqli($servername,$username,$password,$database);
if(!$conn)
{
#ie("connection failed" ,mysql_connect_error());
echo "connection failed";
}
if(!isset($_POST['fname']))
{
$uname = $_POST['fname'];
}
if(!isset($_POST['lname']))
{
$lnam = $_POST['lname'];
}
$qur = "
INSERT INTO test(Username, l_name)
VALUES ('$uname','$lnam')
";
$fetch_qur = "SELECT * FROM test";
$result = mysqli_query($conn,$qur);
$result2 = mysqli_query($conn,$fetch_qur);
while($row=mysqli_fetch_assoc($result2))
{
echo $row['Username'];
echo $row['l_name'];
}
mysqli_close($conn);
?>
Its giving me error as Notice: Undefined index: fname in C:\wamp\www\test\database.php on line 17 as well as for lname.
this code works fine if i use get method . can anyone explain why this is so thanks
Last Name:
– Vish May 07 '15 at 10:44