dongpo2002
dongpo2002
2016-12-31 16:11

如何使用PHP访问由文件生成的SQL数据库

  • php
  • mysql
  • sql

First off, let me say that I'm new to SQL and PHP, so don't hurt my feelings too much, ok? :)

In table.sql, I put

CREATE TABLE `quill-members` (
    `id` int(11) NOT NULL auto_increment
    `user` varchar(32) collate utf8_unicode_ci NOT NULL default '',
    `password` varchar(32) collate utf8_unicode_ci NOT NULL default '',
    `email` varchar(255) collate utf8_unicode_ci NOT NULL default '',
    `regIP` varchar(15) collate utf8_unicode_ci NOT NULL default '',
    `dt` datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY  (`id`),
    UNIQUE KEY `user` (`user`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

In a file called login.php, I have a two forms, one that the user fills out to sign up, the other that the user fills out to sign in. The sign in form will go to a page named something like login.php that processes the information, logs the user in if the credentials are correct, and sends them back to login.php with an error message if their credentials are wrong. The other form will send the information to a file called something like signup.php and will sign the user up and send him/her to their account page/home page, either or.

My question is, how do I access the table "quill-members" from the PHP scripts, if that's possible, and, if not, how I would go about doing this.

I would also like to know if the table made in table.sql will save or not when the user closes the webpage. My guess is no, so if it doesn't save, how do I make it save? I'm using godaddy.com, so if I can set a database up there and access it, that would be good to know too.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换