- hello
- we create our scripte PHP , its a simple scripte of login
form of login see : how to write scripte of login
and a database of users . see how to creat a database of users
how to use our database by scripte PHP .?
- we create a file of name : check.php , this page is of verification : if the username and password
exist at database or no , and in our last file we modife the action of login form
action="check.php" and not "exemple.php" .
we remove the adding scripte in last cour , because we use the new scripte check.php
we create the scripte of check.php
<?php
$username=$_POST['name'];
$password=$_POST['password'];
if ($_POST['sbmit']){
$localhost="localhost"; // the localhost that you have
$bd_username='root'; // the username of your login to phpmyadmin , (as you define)
$db_pass='root'; // the password of your login to phpmyadmin
$db_name="logine"; // the name of database that we create in last cour
$tbl_name="users"; // the name of table thar we need to use
// 1- connect to database
mysql_connect($localhost,$bd_username,$bd_password) or die ("can not connect to database");
// connection to database by 3 parametres
mysql_select($db_name); // for selecting the database we need
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password' ";
// for selecting all fields if username and password are true
$result=mysql_query($sql); // for execut the sql instruction
$num=mysql_num_rows($result); // for counting the number of output result
if ($num!=1 ){
// the number of output result must be 1 and not 0 or 2,3,4 ...
echo "hello ".$username." __ ".password;
}
else echo "error : member do not exist";
}
?>
this is all , try it
thank you very much . in the next we try to set a new edea in our blog
- we create our scripte PHP , its a simple scripte of login
form of login see : how to write scripte of login
and a database of users . see how to creat a database of users
how to use our database by scripte PHP .?
- we create a file of name : check.php , this page is of verification : if the username and password
exist at database or no , and in our last file we modife the action of login form
action="check.php" and not "exemple.php" .
we remove the adding scripte in last cour , because we use the new scripte check.php
we create the scripte of check.php
<?php
$username=$_POST['name'];
$password=$_POST['password'];
if ($_POST['sbmit']){
$localhost="localhost"; // the localhost that you have
$bd_username='root'; // the username of your login to phpmyadmin , (as you define)
$db_pass='root'; // the password of your login to phpmyadmin
$db_name="logine"; // the name of database that we create in last cour
$tbl_name="users"; // the name of table thar we need to use
// 1- connect to database
mysql_connect($localhost,$bd_username,$bd_password) or die ("can not connect to database");
// connection to database by 3 parametres
mysql_select($db_name); // for selecting the database we need
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password' ";
// for selecting all fields if username and password are true
$result=mysql_query($sql); // for execut the sql instruction
$num=mysql_num_rows($result); // for counting the number of output result
if ($num!=1 ){
// the number of output result must be 1 and not 0 or 2,3,4 ...
echo "hello ".$username." __ ".password;
}
else echo "error : member do not exist";
}
?>
this is all , try it
thank you very much . in the next we try to set a new edea in our blog
No comments:
Post a Comment