{"id":107,"date":"2012-11-08T12:49:19","date_gmt":"2012-11-08T04:49:19","guid":{"rendered":"http:\/\/www.yeetrack.com\/post\/2012-11-08\/php%25E5%2590%2591%25E8%25A1%25A8%25E4%25B8%25AD%25E6%258F%2592%25E5%2585%25A5%25E6%2595%25B0%25E6%258D%25AE"},"modified":"2013-04-20T17:28:47","modified_gmt":"2013-04-20T09:28:47","slug":"php%e5%90%91%e8%a1%a8%e4%b8%ad%e6%8f%92%e5%85%a5%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=107","title":{"rendered":"php\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e"},"content":{"rendered":"<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4f7f\u7528insert into \u8bed\u53e5\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\u3002\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<p><!--more--><\/p>\n<p> insert into user (username,passwd,email) values ('hello','hello','hello@hello.com')\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u521b\u5efa\u4e86mydatabase\u5e93\u548cuser\u8868\uff0c\u5e76\u5728\u8868\u4e2d\u63d2\u5165\u4e86\u4e00\u6761\u6570\u636e\u3002<\/p>\n<pre config=\"brush:php;toolbar:false;\">&lt;?php \n$link = mysql_connect('localhost','root','toor'); \nif (!$link) { \ndie('Could not connect to MySQL: ' . mysql_error()); \n} \necho 'Connection OK';\n       \n$sql=&quot;create database mydatabase&quot;;\nif(!mysql_query($sql,$link))\n{\necho &quot;\u6570\u636e\u5e93mydatabase\u521b\u5efa\u5931\u8d25&quot; . mysql_error();\ndie();\n}\n       \nmysql_selectdb(&quot;mydatabase&quot;);\n       \n$sql=&quot;create table user \n(\nuserId int not null auto_increment,\nprimary key (userId),\nusername varchar(20),\npassword varchar(20),\nemail varchar(20)\n)&quot;;\nif(!mysql_query($sql,$link))\necho &quot;\u8868\u521b\u5efa\u5931\u8d25&quot; . mysql_error();\n       \n$sql=&quot;insert into user (username,password,email) values ('youthflies','1234','hello@hello.com')&quot;;\nif(mysql_query($sql))\necho &quot;\u63d2\u5165\u6570\u636e\u6210\u529f&quot;;\nelse\necho &quot;Failed&quot; . mysql_error();\n       \nmysql_close($link);\n       \n       \n       \n?&gt;<\/pre>\n<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e5f\u53ef\u4ee5\u8bfb\u53d6post\u8fc7\u6765\u7684\u6570\u636e\uff0c\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u5982\u4e0b\u9762\u5c31\u662f\u5c06\u7528\u6237\u8f93\u5165\u7684\u4fe1\u606f\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002register.php\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre config=\"brush:html;toolbar:false;\">&lt;html&gt;\n&lt;body&gt;\n&lt;form method=&quot;post&quot; action=&quot;doRegister.php&quot;&gt;\nusername: &lt;input type=&quot;text&quot; name=&quot;name&quot;&gt; \n     \npassword: &lt;input type=&quot;password&quot; name=&quot;password&quot;&gt; \n     \nemial: &lt;input type=&quot;text&quot; name=&quot;email&quot; &gt; \n     \n&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;\u6ce8\u518c&quot;&gt; \n&lt;\/form&gt;<\/pre>\n<p>doRegister.php\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre config=\"brush:php;toolbar:false;\">&lt;?php \n$link = mysql_connect('localhost','root','toor'); \nif (!$link) { \ndie('Could not connect to MySQL: ' . mysql_error()); \n} \necho 'Connection OK';\n   \n$sql=&quot;create database mydatabase&quot;;\nif(!mysql_query($sql,$link))\n{\necho &quot;\u6570\u636e\u5e93mydatabase\u521b\u5efa\u5931\u8d25&quot; . mysql_error();\ndie();\n}\n   \nmysql_selectdb(&quot;mydatabase&quot;);\n   \n$sql=&quot;create table user \n(\nuserId int not null auto_increment,\nprimary key (userId),\nusername varchar(20),\npassword varchar(20),\nemail varchar(20)\n)&quot;;\nif(!mysql_query($sql,$link))\necho &quot;\u8868\u521b\u5efa\u5931\u8d25&quot; . mysql_error();\n   \n   \n$sql=&quot;insert into user (username,password,email) values ('$_POST[name]','$_POST[password]','$_POST[email]')&quot;;\nif(mysql_query($sql))\necho &quot;\u63d2\u5165\u6570\u636e\u6210\u529f&quot;;\nelse\necho &quot;Failed&quot; . mysql_error();\n   \nmysql_close($link);\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4f7f\u7528insert into \u8bed\u53e5\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\u3002\u8bed\u6cd5\u4e3a\uff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[33],"tags":[24,7],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-coding","tag-php","tag-7"],"views":3801,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=107"}],"version-history":[{"count":2,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":418,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions\/418"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}