duanmei1536 2015-03-01 20:22
浏览 34

特定事件后,在mySQL表行中通过php更新单个INT

I have a account Database for a Android App. In this Database i have the rows "_id, username, password, function, login_counter".

Now i want to auto update the row login_counter after the frist login from this user. The Default value is "0". After the 1st login it must change to "1"

(Reason: This system shall prevent the 2nd user to use the login data from the 1st user', after the 1st Login from User 1 the Data is stored to an local sqlite DB, all other logins ar automatic, no logout is provided)

So how can i do this via php? I think to do this via php is the simplest way to do it. If i'm wrong please tell me the better way to do it (Such as directly from android (java)?) i dont know, tell me pls :)

Currently i have only the db_connect and the add_user php files. Works great from browser :)

Ok i hope you understand what i want. And that you can help me :)

Thank You!

Edit 1 (MyCode)

<?php
// DB Verbingung Aufbauen
include("connect.inc.php");

// Diese Funktion wird verwendet, um einen Benutzer anzulegen.
function add_user($username, $password, $function) {
// Passwort verschlüsseln
$password = md5($password);

//Gegen SQL-Injections schützen
$username = mysql_real_escape_string($username);

// MySQL-Query generieren und ausfuehren
$sql = "INSERT INTO user (username, password, function)
    VALUES ('$username' , '$password', '$function')";

    if(mysql_query($sql))
        echo "Benutzer '$username' erfolgreich angelegt!<br> Daten: <br>    Passwort: '$password'<br> Funktion: '$function'";
    else
        echo "Fehler beim Anelgen des Benutzers '$username'!<br>";
}

//Den Login Counter nach dem ersten Login eines Users Automatisch von 0 auf 1 setzten
 function update_login_counter ($login_counter) {
//TODO: Code einfügen fürn Updater

}

//User adden
add_user 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程
    • ¥20 我要一个分身加定位两个功能的安卓app
    • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题