NOKIA

pages of blog

Thursday 10 July 2014

HTML , how to create a form

hello .
to create a form in HTML , we must define the action and the method
the action is The value of the page that we're going to 
the method is POST or GET , It is the matrix which is stored inside the values ​​of the variables of the current page , To be sent to the next page

<form action='page2.html' method='POST'>
</form>

ok , here we need an input for put the data , like name , password , image or file uploaded , text befor searching, buttom ...., All of these things called input , We put them inside the form 

<input type="" name="" value=""> 
 all input Must contain
 the type : text , password , submit ,file 
the name : You choose the name, because you need the next page you made ​​commitments for programming.
the value : it is text that is writting at the input . 

<html>
<head>
<title>
page 1 
</title>
</head>
<body bgcolor='red'>

<form action='page2.html' method='POST'>
 <p><input type="text" name="name" value="put the name here"></p>
 <p><input type="password" name="password" value="put the password here"></p>
 <p><input type="submit" name="submit" value="enter"></p>
</form>

</body>
</html> 

the result : 









try it your self . 
the next cour : how to create table by HTML

HTML , The paragraph

the paragraph in html , is easy and sample , how do it ?

 To separate paragraph for paragraph , we use <p>
also , we use <br>  for write Each line alone : <br>
we use <b>  for write a line in Boor : <b>

<html>
<head>
<title>
My first page 
</title>
<body bgcolor='red'>
<p> hello </p>
<p> this is my first page , i learn html with the blog php-followers , it is sample and easy </p>
<br> but ..! you must look at futur 
<br> because the programming is very good with us 
<br> ok <br>
<b> thank you very much ... </b> 
</body>
</html> 

try it your self ....! 

the result  





the next : how to use the form in HTML

HTML , how to set a background image or color to page

hello 

for set a background of image , you must give the source of image that you would like . 
exemple 

this image :





we give the source of this image , in net or in pc
the source is : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinN0R7drIHl1keR8it2BXk6vATZ4ZJjpcaabDSNpAaM7qsmLAzwXXMVRkPaZmGuunIujESL-uUbYPHty9tnEBDzc-7kn95rhJHodUquaTLapWC1gSmHA3Rq7n2qrmg-QaOrIO4G8QNosXA/s1600/nature.jpg

ok . 


write backgound='source of image '


<html>
<head>
<title>
</title>
</head>
<body background='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinN0R7drIHl1keR8it2BXk6vATZ4ZJjpcaabDSNpAaM7qsmLAzwXXMVRkPaZmGuunIujESL-uUbYPHty9tnEBDzc-7kn95rhJHodUquaTLapWC1gSmHA3Rq7n2qrmg-QaOrIO4G8QNosXA/s1600/nature.jpg'>
</body>
</html>


and  if you would like to set a color then write bgcolor='the color or code color'


<html>
<head>
<title>
</title>
</head>
<body bgcolor='red'>
</body>
</html>

you can give the code of color html from this site : click here


we see you in the next cour : the Paragraph in HTML

learn HTML easily : the body

With HTML you can create your own Web site.

html : Hypertext Markup Language , language simple and easy for create web site 
html is  static language for create page internet

the body of html

<html>
<head>
<title>
YOUR  TITLE PAGE
</title>
</head>
<body>
THE BODY OF YOUR SITE HERE
</body>
</html>

try it your self , by create a file (exemple.html) and put the code source in the file. 

the next : HOW TO SET A BACKGROUND OF YOUR PAGE HTML

use RANDOM function in php , with a database (by class)

hello ,
the RANDOM function is the best and easy . read here
but what is the interest ? 

we use this edea by writting a script PHP .
if the result of random function exist at our database that we will create then do no thing 
else add this result value to this database
we create a database . called RND . If you do not know how to creat a database read here
and , we create a table called  rnd_table , Contains Only one field 
called  val : int(20) 
ok .

Such as habit we create a scripte PHP for Contacting to our database RND
but in   this cour we use the  class . 
if you do not know what is a class read PHP class 
we create a file (Ourclass.php) .
<?php
 class contact_db{
public $localhost="localhost";
    public $username="root";
    public $password="root";
    public $db_name='rnd';
    public $tbl_name="rnd_table";
  public $r=array();
 function __construct(){ // this function is Present in the time of calling to class
 mysql_connect($this->localhost,$this->username,$this->password) or die ('can not connect to data base ');
mysql_select_db($this->db_name) or die('can not select database ');
echo $db_name;
}
 function get_elements_db(){ // this function get all elements of database and puts them in array
$sql="SELECT * FROM $this->tbl_name";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if ($num==0) echo "sory , no elements !!";
else {
$j=0;
while ($rr=mysql_fetch_array($result)){
$r[$j]=$rr['val'];
echo $r[$j]."<br>";
 $j++;
}}}
}
?>
 
ok , the scripte ourclass.php give all values from table of database that we create , 
if no data , then it show (sory , no elements !!) 

we creat a new file called (index.php) and we use the last scripte befor give a random value for Every time .
but , here we add a test , in our script if the value exist at our database show true else show false

to be continued ... :) 


 

Wednesday 9 July 2014

function random in PHP


hello

how are you

i hope that you are fine !!

our cour is to use the RANDOM  : it is a function

in php is called rand , the parametre is 2 integers

from , and to

exemple : rand(1,10) may be = 1 or 2 r... to 10

ok ... we try to write a script PHP using this function

<?php

$rnd=rand(1,10);

echo $rnd;

if ($rnd<5) echo "lose";

else echo "wine";

?>

ok ... save this file in c:\appserv\www\

set the name of file rnd.php

try it .....

its simple and very easy

thank you , we hope to see you in next cour


Tuesday 8 July 2014

Cour 5 : how to use database by our scripte PHP

- 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 
 

cour 4 : creat database and table In order to get it to login form

we need in this cour to create a database of user , its sample and easy :
we define for the user :
1- id
2- username
3- password
the database is a collection of tables .
we need in our database , one table
ok . this good
Applied works : 


You have you installed Appserv from  (here)
insert in the adress of your browser : localhost/phpmyadmin





enter the username and password ; (root , root) , and this pursuant to configuration in the time of install appserv 





1-enter the name of your database (logine)  and click at (creat)
the database may be Contains table or more .
2- create a table in this database , the name is (users) and contains 3 Fields






the fields are : 
the id : of type INT (20) and (auto increment) and it is the key 
the usernmae : of type VARCHAR (20) 
the password : of  type VARCHAR (20) 



in our cour we set a new user 
id = 1
username= jojo
password = 112233 

i export my table befor you . in format SQL , you need this table
If you just do not understand 

-- phpMyAdmin SQL Dump
-- version 2.10.3
-- http://www.phpmyadmin.net
--
-- Serveur: localhost
-- Généré le : Mar 08 Juillet 2014 à 20:40
-- Version du serveur: 5.0.51
-- Version de PHP: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Base de données: `logine`
--

-- --------------------------------------------------------

--
-- Structure de la table `users`
--

CREATE TABLE `users` (
  `id` int(20) NOT NULL auto_increment,
  `username` varchar(20) NOT NULL,
  `password` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

--
-- Contenu de la table `users`
--

INSERT INTO `users` VALUES (1, 'jojo', '112233');

Monday 7 July 2014

SQL

SQL Structured Query Language 
Read all from here


in the next cour , we define how to create database . 
id 
username
password

bye

Tuesday 24 June 2014

cour 3 : what is the action of our login form ? (PHP)

hello .
in cour 1 and 2 , we create a login form by HTML and CSS 
in this cour we ask this question :

what is the action of our login form ? what is the Interest ? 

ok , in this point , we need a edia befour starting . 
1-the user enter a username and password 
2-i say that only if user enter (username="admin" and password="admin")  . he can sees "hello" at Level of our page exemple.php . else he sees "error".

ok , its simple , What do you think that we are testing
  
open your file (exemple.php) and add this code PHP : 
  




you can learn about PHP from all of PHP
we define 2 variables , $username and $password  
$username give its value from $_POST['name'] ( value of input of name='name') by the method POST . 
the $_POST is Matrix help us to give the values of different  input as last input and the input of password .
$password , The same thing ,but it give his value from $_POST['password'] (the second input) 

ok , if the value of $username='admin' and $password='admin' then show (in php echo "") hello
else show error.

so , i say that we need a data base , no only (admin)  can see "hello" 
all users can see this , but if they are registered at data base . 

in the next cour , we use to create a data base , and we know what is SQL , and how to use it . 

i hope that the cour is simple and easy , try to get the correct result .

reminder : 
Do not forget, that you move your 2 files (exemple.php and style.css )  to directory    (c:\appserv\www\) 
if you want to try your page at Browser , write at adress ( localhost/exemple.php) 

ok . that's all 







thank you . 
yassine