Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbcon=null;
- function connect_db()
- {
- global $dbcon;
- $dbcon=mysqli_connect("localhost", "root", "","classicmodels");
- if (!$dbcon)
- {
- echo( "<b>Unable to connect to the database server at this time.</b>" );
- exit();
- }
- return $dbcon;
- }
- function close_db()
- {
- global $dbcon;
- mysqli_close($dbcon);
- }
- ?>
- <?php
- include "newdb.php";
- $dbcon=connect_db();
- ?>
- <?php
- $username=$_POST["username"];
- $password=$_POST["password"];
- //$username='selva';
- //$password='password';
- $flag=0;
- $statement="SELECT userid FROM users where username='$username' and password='$password'";
- //echo $statement;
- //exit();
- $result=mysqli_query($dbcon,$statement);
- while($row=mysqli_fetch_array($result) )
- {
- $flag=1;
- }
- close_db();
- if($flag==1)
- {
- $myObj=new \stdClass();
- $myObj->result = "1";
- $myJSON = json_encode($myObj);
- echo $myJSON;
- exit();
- }
- else
- {
- $myObj=new \stdClass();
- $myObj->result = "2";
- $myJSON = json_encode($myObj);
- echo $myJSON;
- exit();
- }
- ?>
Add Comment
Please, Sign In to add comment