Skip to content Skip to sidebar Skip to footer

Android Login To Mysql Database

Hello guys I'm doing an simple login system in android to mysql database online. This is what I've tried so far: MainActivity: protected String doInBackground(String... args

Solution 1:

(Comment to answer, as requested)

Instead of all of this:

$result = $stmt->fetch(PDO::FETCH_ASSOC); 
$user = $result['username']; 
$affected_rows = $stmt->rowCount(); 
if($affected_rows >= 1){ 

try this under your $stmt->execute(array... line

if($stmt->rowCount() > 0) 
  { echo"Exists"; }
else { echo"Does not exist"; }

or see this answer where I got this from.

Solution 2:

http://www.php.net/manual/en/pdostatement.rowcount.php

*PDOStatement::rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object.

If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.*

Check $result to see if you got a username or not.

Post a Comment for "Android Login To Mysql Database"