dongpo2002 2016-12-31 16:11
浏览 42
已采纳

如何使用PHP访问由文件生成的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条回答 默认 最新

  • drxm72811 2016-12-31 16:19
    关注

    Having a table definition written down doesn't automatically generate a table. You'll have to create a database first, then create the table in the database, connect to the database from within PHP, and then write functions to operate on the database from within PHP.

    I suggest following some tutorials on PHP and MySQL. This W3Schools tutorial might be a good starting point.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿