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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题