본문 바로가기

개인공부

안드로이드 : 회원 관리 프로젝트(DB구축)

반응형

 

데이터베이스 구축

 

카페24에서 DB베이스를 구축합니다

 

CREATE TABLE 'USERH'(
	userID VARCHAR(20) NOT NULL,
    userPassword VARCHAR(20) NOT NULL,
    userName VARCHAR(20) NOT NULL,
    userAge INT NOT NULL,
    PRIMARY KEY(userID)
);

 

 

<?php
    $con = mysqli_connect("localhost","id","password","id");

    $userID = $_POST["userID"];
    $userPassword = $_POST["userPassword"];

    $statement = mysqli_prepare($con, "SELECT * FROM USER WHERE userID = ? AND userPassword = ?");
    mysqli_stmt_bind_param($statement, "ss", $userID, $userPassword);
    mysqli_stmt_execute($statement);

    mysqli_stmt_store_result($statement);
    mysqli_stmt_bind_result($statement,$userID, $userPassword, $userName, $userAge);

    $response = array();
    $response["success"] = false;

    while(mysqli_stmt_fetch($statement)){
        $response["success"] = true;
        $response["userID"] = $userID;
        $response["userPassword"] = $userPassword;
        $response["userName"] = $userName;
        $response["userAge"] = $userAge;

    }
    echo json_encode(&response);
?>

Login.php

 

<?php
    $con = mysqli_connect("localhost","id","password","id");

    $userID = $_POST["userID"];
    $userPassword = $_POST["userPassword"];
    $userName = $_POST["userName"];
    $userAge = $_POST["userAge"];

    $statement = mysqli_prepare($con, "INSERT INTO USER VALUES (?, ?, ?, ?)");
    mysqli_stmt_bind_param($statement, "sssi", $userID, $userPassword, $userName, $userAge);
    mysqli_stmt_execute($statement);

    $response = array();
    $response["success"] = true;

    echo json_encode(&response);
?>

Register.php

반응형