Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set up DB Now What? <Newbie Question

    Ok i have a Data Base set up for practice so i can try and learn PHP/MySQL

    I used phpMyAdmin to Create the following

    DB: test
    Table: Register
    Fields: ID -Set to unique...What is Unique for?
    Login
    Password
    Email

    What are some example is can do to learn this stuff...

    What i want to do is be able to add a new ID,Login,PW, and E-mail from a form...

    This is to serve no purpose but to help me learn PHP and MySQL..I'v Read many tutorials but none seam to teach on my level...Yes Im Dumb....Not really im just slow at learning and need to see real examples to be able to comprehend stuff...

    Give me some example of how i could use this data base...Keep it simple for now and i will build on from there...

    Note: it took me a week just to install phpMyAdmin and create a Db with it....Thats how slow i am...Talk to me like im Dumb...I wont take offence to it..

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    o k i w i l l t a l k v e r y s l o w w w l y. G o t h r o u g h t h i s t u t o r i a l :


    http://www.mysql.com/articles/ddws/
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    From the top: (well a few lines down anyway)

    unique - means any value held by that field in that table CANNOT be the same as another value of the same field - ie. if you tried to insert '3' into that field twice you'd get an error.
    personally I'd set ID to [auto-increment] (every time a value is set it is set at one higher than the highest value ever entered) and [index] (index tells mysql to associate that field with any search facility you have going - basically it can find '49' from a 100 entry field by going '1'? = higher / 50 = lower / 25 = higher etc - which is faster than doing 1 = no 2 = no 3 =no )

    login I assume is a username/tag value like 'Ökii' and I 'spect is
    varchar(50) or close.

    password - check out mcrypt() / crypt() and md5() at php.net - so you can give a few bits of encrytion to the stored values.

    email - synonym of login - I guess your visitors might want to either remember their username/tag/login or email addr - either would be tied to their password.

    Getting on toward some code

    PHP Code:
    if(isset($pass) && $pass!=="") {
    // open database

    $cal mysql_query("SELECT * FROM 'users' WHERE login='$logintxt' OR email='$emailtxt'");
    $d mysql_fetch_array($queri);
    if(
    $d['password'] === $passtxt) {
    echo 
    'well done logged user';
    }
    else {
    echo 
    'bad pass';
    }
    }
    else {
    echo 
    'no pass';

    I doubt that above is going to make your life any easier (partly as it's fly typed so prone to the odd parse error ) - anyway - you'd probably want to either have the user login with [login] or [email] accompanied by a [password] or do most of that by cookies and sessions. Best to start with forms though.

    Give us all a shout on the next glitch you hit - or just pick holes in that code snippet (or let others do the same)
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Spookster
    o k i w i l l t a l k v e r y s l o w w w l y.
    *cough* - that should be Ökii (weird o and two i's) - and I must have talked slowish as I took over 6 mins typing that :yikes: - drat, where's the yikes smiley gone?
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •