PDA

View Full Version : Set up DB Now What? <Newbie Question



Squintz
Jul 30th, 2002, 05:19 PM
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.. :)

Spookster
Jul 30th, 2002, 07:42 PM
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/

Íkii
Jul 30th, 2002, 07:48 PM
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


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
Jul 30th, 2002, 07:52 PM
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?