Search This Blog

Sunday, October 23, 2016

HOW SESSION WORKS ? LOGIN AND LOGOUT UNDERSTANDING OF SESSION

Hi,
Now I am studying basic PHP coding. So trying to make a website without using Javas_script , Jquery, Ajax or any framework. So now I am facing lot of problems. But I get a major problem actually not problem it's difficult to understand to me and all of the students, that is session .  So Today I am going to share some of experience and understanding about session. I guess it will very helpful for beginners.

Login and Logout by using SESSION :

Yes I thing login and logout is the main work of a session. And yes it true. Now I am trying to make you understand how SESSION works to maintain this login and logout.  And could not give anybody to visit any page without UserName or PassWord.

Code : 
1. phpTagstart   session_start();// you are just start  session on your page. Normally it should open the        //first login check file in php .

2.  $signal="user is valid";     if(isset($_SESSION["anytext"]))
     $signal=$_SESSION["anytext"]; 
 //  Then wright this in your second line.  It means that a  //validation text which is set by you in SESSION and you push to a variable called $signal .
// this "anytext" could be anything.

3.  
if($signal=="user is valid")  {  phptegend  // And thirdly you should wright this line to check that  this text //was in this SESSION so this session page or form is valid. Some people are also called this line as //form validation.  

Wright all your php,html,java script everything in this gap  between  point 3 and point 4 .  

4. phpTagstart  }  phptegend     // Look carefully in last line (pont 3 ) we did not complete "{ " bracket.  So at the //end of the page we should use this line to close the bracket .   

  All blue code should be keep into php_tags .

( That's all. But it is not only  technich to maintain session. It's just easiest way as my opinion .)


Some Works of SESSION :

Hare are some basic works of SESSION:

1. SESSION a associative array. (It's like a global array but not global array. It's an array who can carry values from one page to another page )
    SESSION is a common space where can access from every page.

2. 
SESSION should start with this   session_start();  function declaration . After declaring one time it will continue in every page and carry value globally until session destroy. 

3. But we need to write session_start(); in every page at the upper site. I mean just after declaring 

4. We can push value form any page in session like this  $_SESSION["variable_name"] ; (no need use $) 

5. And get all value form session from every page under the session like 
 $variable = $_SESSION["variable_name"];  . But you must should see at beginning of the page should have  session_start();

6. We can also directly print any value from session like this echo "Welcome ".$_SESSION['variable_name'] ;  But make sure that this variable already pushed in the session .
THANK YOU

Use of sort function to sort a array in C++

It's a example of doing sort by using sort function in C++. We can use this function to sort
normal any numbers very easily .
#include
using namespace std;
int main()
{
    int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
    int n = sizeof(arr)/sizeof(arr[0]);
    sort(arr, arr+n);
    cout << "\nArray after sorting using "
         "default sort is : \n";
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    return 0;
}

Wednesday, October 19, 2016

SQL Database Joining Tutorial. Inner join, Left join, Right join, Full outer join.

Hallo All.
As a student of Database I realize that maximum student have some difficulty to understand JOINNING in SQL.. Now I am trying to make a little tutorial example to understand JOINNING. Hope you can understand what is joining and how it works. Let’s start…

Assuming you're joining on columns with no duplicates, which is a very common case:
·         An inner join of A and B gives the result of A intersect B, i.e. the inner part of a Venn diagram  intersection.
·         An outer join of A and B gives the results of A union B, i.e. the outer parts of a Venn diagram union.

Examples:

Suppose you have two tables, with a single column each, and data as follows:
A    B
-    -
1    3
2    4
3    5
4    6
Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.
Inner join

The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables.
i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a = b.b;

a | b
--+--
3 | 3
4 | 4

Left join

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.
A left outer join will give all rows in A, plus any common rows in B.
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a = b.b(+);

a |  b
--+-----
1 | null
2 | null
3 |    3
4 |    4



Right join

The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match.
 A right outer join will give all rows in B, plus any common rows in A.
select * from a RIGHT OUTER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a(+) = b.b;

a    |  b
-----+----
3    |  3
4    |  4
null5
null6

Full outer join

The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2). The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.
A full outer join will give you the union of A and B, i.e. all the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
select * from a FULL OUTER JOIN b on a.a = b.b;

 a   |  b
-----+-----
   1 | null
   2 | null
   3 |    3
   4 |    4
null |    6
null |    5


Restrict File Upload by File Type in Oracle Apex

If you want to restrict file upload by file type/extension/format you can follow the below steps.  Goto File Browser Item --> Advanced --...