So I java a php script that is supposed to receive information from a java file but for some reason I get this error
Notice:Undefinedindex:user_nameinC:\xampp\htdocs\login.phponline3
Notice:Undefinedindex:passwordinC:\xampp\htdocs\login.phponline4
loginnotsuccess
Anyone know how to fix it? Java code:
try {
Scanner x;
URL url = new URL("http://localhost:1234/login.php");
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
Formatter form = new Formatter(con.getOutputStream());
form.format("user_name=123");
form.format("&password=123");
con.getInputStream();
form.close();
x = new Scanner(con.getInputStream());
while(x.hasNext())
{
System.out.print(x.next());
}
x.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PHP code:
<?php
require "conn.php";
$user_name = $_POST['user_name'];
$user_pass = $_POST['password'];
$mysql_qry = "SELECT * FROM employee_data WHERE username LIKE '$user_name' AND password LIKE '$user_pass';";
$result = mysqli_query($conn,$mysql_qry);
if(mysqli_num_rows($result) > 0)
{
echo "login success";
}
else
{
echo "login not success";
}
?>