Easy Web Programming With PHP plus HTML 5 - part 3. How to Passing Variables Between Pages

3.1 Passing Variables Between Pages
A web page often to process the values obtained by other sites. So that PHP can analyze variables between pages. There are many ways to analyze the value between variables, one of which is through a URL.
If before calling a PHP variable. Other pages directly using the variable name now. You have to write add a special syntax. 
This time he will try to analyze the value of the variable use $ _REQUEST ['variable'], whereas in the module Below you can see a more sophisticated analysis formed using $ _POST. Create a file with halaman1.php code like the following:

<Html>
<head>
<? php
$ Name = "BambangPamungkas";
print "<title>";
print "Analyze the name." $ Name;
print "</ title>";
?>
<body>
<H1> Variable parsing demo between pages </ h1>
Value analysis: <br/>
<B> Name </ b> = <b> <? php print $ name?> </ b>
<br/>
<? php
print "<noscript>"; 90
print "Enable JavaScript";
print "</ noscript>";
print "button <
onclick = window.location = 'halaman2.php? name = $ name '> Try Click
To display the name of the second page! </ Button> ";
print "</a>"
?>
</ Body>
</ Head>
</ Html>

After opening will look like this, click the button, but prior to first make halaman2.php with code like this
3.1.1 Halaman1.php display when not shown
Then create a second code that will display the values parsed of halaman1.php in halaman2.php use code as follows:

<html>
<head>
<title>
<? php
print "Second Page To Display name
". $ _ REQUEST ['name'];
?>
</ title>
<body>
<h1> This is the second page </ h1>
<? php
$ name = $ _REQUEST ['name'];
then print out "The name is taken from the first page
is .... <b> ". $ name." </ b> ";
?>
</ body>
</ head>
</ html> 91

If the button is clicked in halaman1.php, appears halaman2.php like the following.
3.1.2 display halaman2.php

SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar