Passing variable values from URL with PHP Get method

Today we look at how can we sent variable data from one page to another page through url. In real life web application we need to send data from one page to another page. 
To do this, we will open two pages. First page contains a URL with variable value and second page collects that value using PHP $_GET method. We name the first page is first_page.php and second page is second_page.php.  So the first page looks like this

<a href="second_page">Second Page</a>

Save this page in your localhost folder. This is a HTML URL example page. Now we see how to send data from url. To do this you need to put a question mark in the URL and then you need to write your variable with values. Now the page is

<a href="second_page?name=Sharif">Second Page</a>

In this portion we just set one value but in real life problem we need to send two or more values from url. To send two or more values you need to set & operator after each variable. So the page is
<a href="second_page?first_name=Sharif&last_name=Rahman">Second Page</a>

Now we catch the variable value from first page and we show it in the browser. Open the second_page.php file and write the following code.

<?php
echo $_GET['first_name'];
echo $_GET['last_name'];
?>
Save the code and try to understand the output. In this tutorial we use PHP $_GET method to catch the URL value. We have a great tutorial on PHP $_GET method.

Step by step PHP video tutorials from start to finish: part-1

PHP free video tutorials:

Hello everyone, this is right place to learn PHP from video tutorials. We consolidate all tutorials from thenewboston and we arrange all PHP video tutorials with step by step manner. Though we have lot of written tutorials on PHP but we think that video tutorials are more effective than written tutorials. That's why we introduce PHP video tutorials only for you. So complete our all PHP video tutorials with step by step procedure. I think you will learn many thinks from our tutorials.

To download or watch tutorials just click on skip add button. In this part we give some tutorials for beginners. So start your PHP learning with video tutorials from now.

Video Tutorials explanation: 

Introduction to PHP tutorial describe what is PHP and why we should use PHP. This is your beginning part then you need to watch how to install PHP environment with Installing XAMPP part -1 and part 2 tutorials. Now it is time to create first PHP file and script. You can learn this Creating Your First PHP file and Writing Your First PHP file and The last part give you some idea about phpinfo function. 

We think you complete those tutorials. If you face any problem with those tutorials please inform us. We try our best to solve your problem. Thanks. 

Ultimate Fade Slideshow - Safari and Chrome

PHP Login Script with Remember Me Feature

In "Remember Me" feature that basically keeps users logged into the website, even after they've closed the browser so that the next time they come, they won't have to login again manually. "Remember Me" feature, use cookies in addition to sessions

In login.php, when a user chooses to be remembered, two cookies are set on the user's computer. Actually it is one cookie, but one that contains two important pieces of information: the username and the md5 encrypted password. What is a cookie anyways? It is a temporary file that is stored on the user's computer on behalf of the website in order to hold information that is important to the website. However, it also gets deleted when the user decides to log out, as you will soon see.


Click here to get the Reference web url






Control Structures in PHP: IF

The if construct is one of the most important features of many languages, PHP included. It allows for conditional execution of code fragments. PHP features an if structure that is similar to that of C:

if (expr)

statement

As described in the section about expressions, expression is evaluated to its Boolean value. If expression evaluates to TRUE, PHP will execute statement, and if it evaluates to FALSE - it'll ignore it. More information about what values evaluate to FALSE can be found in the 'Converting to boolean' section.

The following example would display a is bigger than b if $a is bigger than $b:

  

<?php

if ($a > $b)

echo "a is bigger than b";

?>

Often you'd want to have more than one statement to be executed conditionally. Of course, there's no need to wrap each statement with an if clause. Instead, you can group several statements into a statement group. For example, this code would display a is bigger than b if $a is bigger than $b, and would then assign the value of $a into $b:

   

<?php

if ($a > $b) {

echo "a is bigger than b";

$b = $a;

}

?>

If statements can be nested indefinitely within other if statements, which provides you with complete flexibility for conditional execution of the various parts of your program.

file append in php

<?php

if(isset($_POST['name'])&&isset($_POST['age'])&&isset($_POST['fname']))
{
  $name=$_POST['name'];
  $age=$_POST['age'];
  $fname=$_POST['fname'];
  if(!empty($name)&&!empty($age)&&!empty($fname))
  {
      $file=$_POST['fname'].'.txt';
      if(file_exists("$file"))
      {
      $hand=fopen("$fname".'.txt','a');
      fwrite($hand,$name." ");
      fwrite($hand,$age."\r\n");
      fclose($hand);
      }
      else
      echo 'file not exist';
  }
  else
      echo 'all fielsd are not filled';

}

?>

<form action="file-append.php" method="POST">
name : <input type="text" name="name">
age  : <input type="text" name="age">
file name : <input type="text" name="fname">
.txt
<input type="submit" value="submit">
</form>

output :

note :
1) try with no input datat and click submit button
2) try with don't fill all text boxes and click on submit button
3) try with fill all text boxes and click on submit button
4)check  " test.txt " file