How do create a database table?

Discussion in 'PHP' started by MrLeN, Aug 13, 2012.

  1. #1
    Note: My original question is answered. Now I have a new question, relating to the same database

    Skip to the new question

    I didn't make a new thread, because when someone answers, they probably need to know the database structure I am using.

    ===================

    I am following this tutorial:

    http://www.phpeasystep.com/phptu/6.html

    I come to this step:

    
    [color=red]STEP1: Create table "members"
    For testing this code, we need to create database "test" and create table "members".[/color]
    
    CREATE TABLE `members` (
    `id` int(4) NOT NULL auto_increment,
    `username` varchar(65) NOT NULL default '',
    `password` varchar(65) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=2 ;
    
    -- 
    -- Dumping data for table `members`
    -- 
    
    INSERT INTO `members` VALUES (1, 'john', '1234');
    
    
    Code (markup):
    I am using phpMyAdmin

    Where do I paste that code in phpMyAdmin, to create the table?

    Also, are those apostrophe's supposed to be leaning back?

    ie: should `members` be 'members'?

    I pasted the code into the "SQL Queries" page and clicked "Go", but nothing seemed to happen.

    What am I doing wrong?
     
    Last edited: Aug 13, 2012
    MrLeN, Aug 13, 2012 IP
  2. MrLeN

    MrLeN Well-Known Member

    Messages:
    406
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Never mind, I did it right the first time :)

    I just paste the code in SQL queries.

    I expected some message which says: "Succesful" or something.

    But then I noticed that there's a new table listed on the left, called "members".

    Then I tried to log in from the website, and it worked!

    Ok, I can continue now.
     
    MrLeN, Aug 13, 2012 IP
  3. MrLeN

    MrLeN Well-Known Member

    Messages:
    406
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    120
    #3
    New Question!

    Actually, I have another question.

    Now I have created a page called register.php

    Here's the form I have so far:

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>Register</title>
      <link href="/style.css" type="text/css" rel="stylesheet" />
    </head>
    
    <body>
      <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/head.php' ?>
    
      <h3>Register</h3>
    
      <table summary="" cellpadding="5" cellspacing="0" border="0">
        <tr>
          <td>Username:</td>
    
          <td><input type="text" name="username" /></td>
        </tr>
    
        <tr>
          <td>Password:</td>
    
          <td><input type="text" name="password" /></td>
        </tr>
    
        <tr>
          <td>Password (again):</td>
    
          <td><input type="text" name="password2" /></td>
        </tr>
    
        <tr>
          <td>Email:</td>
    
          <td><input type="text" name="email" /></td>
        </tr>
    
        <tr>
          <td> </td>
    
          <td><input type="submit" name="Submit" value=
          "Register" /></td>
        </tr>
      </table><br /><br /><?php include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/foot.php' ?>
    </body>
    </html>
    
    
    Code (markup):
    As you can see, I followed a tutorial to create the database. But it doesn't have an email or username table.

    So, what do I need to do now? Do I have to go to the database and add tables?

    Or, can I write some code that will create the tables after the form submission?

    Please take it easy with the response, because I am just learning. I don't understand many things, but I am trying!
     
    Last edited: Aug 13, 2012
    MrLeN, Aug 13, 2012 IP