将$ _POST添加到mysql数据库

时间:2015-11-16 05:15:10

标签: php android mysql database

我可以通过PHP从$_POST向MySQL数据库插入新记录吗?

我的PHP当前代码:

<?php
    // if text data was posted
    if($_POST){
        print_r($_POST);
    }
?>

输出:

(
    [tokenID] => f0g6dSwx_R4:APA91bGic-JFlhehUz6pl2CUqw_8j1OATMXRmrnMjuBXJhzrnIU3pxDJGrpb7jCZpAR4yG8SJWPczxnY9AL1EC03FBnoH6Y6JYTO_Xge92QRXgbuW8u_EfbNAF077dFtlg2w_B__4dv2
    [name] => SIT-Messanger
    [token] => f0g6dSwx_R4:APA91bGic-JFlhehUz6pl2CUqw_8j1OATMXRmrnMjuBXJhzrnIU3pxDJGrpb7jCZpAR4yG8SJWPczxnY9AL1EC03FBnoH6Y6JYTO_Xge92QRXgbuW8u_EfbNAF077dFtlg2w_B__4dv2
    [email] => miketestmailcom
)

1 个答案:

答案 0 :(得分:1)

首先创建新表

CREATE TABLE IF NOT EXISTS (
    tokenID varchar(250), 
    name varchar(100), 
    token varchar(250),
    email varchar(100)
) ENGINE=INNODB;

或使用插入语句

INSERT INTO table VALUES ('tokenID', 'name','token','email');