<?php
$con=mysql_connect("localhost","root","123456") or die (mysql_error);
$db=mysql_select_db("test",$con)or die (mysql_error);
mysql_query("SET NAMES UTF8");
$sql=mysql_query("INSERT INTO user (user,userpass) VALUES ('$user','$pass') ");
mysql_close($con);
?>
นี่ฐานข้อมูล
Code (SQL)
-- phpMyAdmin SQL Dump
-- version 2.10.3
-- http://www.phpmyadmin.net
--
-- โฮสต์: localhost
-- เวลาในการสร้าง:
-- รุ่นของเซิร์ฟเวอร์: 5.5.22
-- รุ่นของ PHP: 6.0.0-dev
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- ฐานข้อมูล: `test`
--
-- --------------------------------------------------------
--
-- โครงสร้างตาราง `user`
--
CREATE TABLE `user` (
`userid` int(20) NOT NULL AUTO_INCREMENT,
`user` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`userpass` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
--
-- dump ตาราง `user`
--
INSERT INTO `user` VALUES (1, 0x626f7373, 0x313233343536);
INSERT INTO `user` VALUES (8, 0x70726172696e7961, 0x363534333231);
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
$con=mysql_connect("localhost","root","123456") or die (mysql_error());
$db=mysql_select_db("test",$con)or die (mysql_error());
if($con)
echo"Connected";
else
echo"connect Faild";
mysql_query("SET NAMES UTF8");
$sql=mysql_query("INSERT INTO user (user,userpass) VALUES ('$user','$pass') ") or die(mysql_error());
?>