okay now the second part
first, you need to have a form in a page.. and in the form you put
action="pagewhere you put the code i gave you" so if your page where you put your code is named aaa.php u ll have something like (assuming it s in the same folder as your form page
Code: Select all
<form name="whatever" method="post" action="aaa.php" />
okay...
In a table you have rows and colomn each row is a different "entry" and each colomn is like the different "value" of the row..
exemple : i can have
TABLE --------- $row[0] --------- $row[1] --------- $row[2] <-- u ll understand later this
user ---------ID --------- user --------- password
------------ 1 ------------ John Doe ------------ 911
------------ 2 ------------ Bush------------ 411
etc etc
okay now usually i want to display what information i have in a row (or in a colomn.
so what i m doiing in my for is
looping through my rows...
Okay in every of my table i use an primary key (id) that is unique and that auto-increment itself.. so every row has a number, and this number is never duplicated..
k i ll explain now
Code: Select all
<?php
/* okay now i create a for (look in phpmanual for the function for).*/
/* my second argument : a content for my variable (wich is $rows) */
/* mysql_fetch_row($result) --> that mean i fetch the row corresponding to my query (wich is everything from my table so i get everything from my actual row)*/
/* Since i'm in a for i create a variable that start at 0 and i increment it*/
/* So now the first line tell that for each row in my table starting at 0 get every info of that row*/
for ($i = 0; $rows = mysql_fetch_row($result); $i++)
{
/* okay the if here.. is very simple i have a form with 2 entry a user and a password and i went to chek if what he entered the one that MATCHED what i have in my db */
/* the $_POST['name of your form field'] is the code in php to retreive whatever value a user entered in a form field (or chekbox or any form object)*/
/* the && mean and so i make a if.. if the value of the field user equals whatever i have in my database ($row[1]) AND if the password he entered match the password i have in my db ($row[2])*/
/*so you understand i created a var named $row and since it s a db and i use mysql_fetch_row i putted every thing in $row but it showed like an array so that mean since i have 3 colomn (id user and password) so saying $row[1] means the colomn user */
if ($rows[1] == $_POST["user"] && $rows[2] == $_POST["password"])
{
/* finally if it s BOTH user and pass correspond i send them at whatever page i wish (using meta refresh.. it s html)*/
print "<meta http-equiv="refresh" content="0; url=../ident.php" />";
}else{
/* well else the your a loser */
print "loser";
}
}
/* take the habit of always closing connection*/
mysql_close($connect);
?>