Jump to content

any tutorial for these php url/link technique?


zgkhoo

Recommended Posts

any tutorial for these php url/link technique in the internet? wat those technique called? php link /url system technique or?

http://www.phpfreaks.com/forums/index.php?action=search

http://chinese2.cari.com.my/myforum/viewsub.php?gid=184

http://www.talkphp.com/showthread.php?p=1804#post1804

<?php header("Location: http://www.domain.com/users/".$session->username."/index.php"); ?>

 

which the red syntax i not very understand and hope to find the tutorial abt these.

 

thanks...

 

 

Say if you had index.php and wanted to have ?action=search then you could do something like...

 

<?php
switch($_GET['action']) {
    case 'search';
    search_page();
    break;
    case 'about';
    about_page();
    break;
}

function search_page {
    echo('You are on the search page.');
}

function about_page {
    echo('You are on the about page.');
}
?>

 

You could also do something like this...

 

<?php
switch($_GET['action']) {
    case 'search';
    include('includes/search.php');
    break;
    case 'about';
    include('includes/about.php');
    break;
}
?>

 

I believe the technique is called query-stringing or something...

 

OOP is Object Oriented Programming, stay away from it until you know all the basics...

The $_GET superglobal is used to pass variables across pages using the url.  For example, if you had "index.php?foo=bar", then you could access that as "$_GET['foo'] = bar".  $_POST is the superglobal mainly used for forms and $_REQUEST is sort of in between.  I've never needed to use $_REQUEST.

The $_GET superglobal is used to pass variables across pages using the url.  For example, if you had "index.php?foo=bar", then you could access that as "$_GET['foo'] = bar".  $_POST is the superglobal mainly used for forms and $_REQUEST is sort of in between.  I've never needed to use $_REQUEST.

 

this technique called?

thanks..

This is data passing via URL. It uses two methods, the $_GET method and the $_REQUEST method. ($_REQUEST is very unstable, do not even use this).

 

http://www.phpfreaks.com/forums/index.php?action=search

http://chinese2.cari.com.my/myforum/viewsub.php?gid=184

http://www.talkphp.com/showthread.php?p=1804#post1804

<?php header("Location: http://www.domain.com/users/".$session->username."/index.php"); ?>

 

The first url:

$action = $_GET['action']; //this will set $action to be "search"

The second url:

$gid = $_GET['gid']; //this will set $gid to be "184"

The third url is a header-redirect. Basically, you are right that it is OOP. They said something like:

$session = new Class();

In their "Class" is a variable called $username, they can call the variable within the class by saying

$session->username

The code above basically tells the browser to get the person's username from a session variable (using the Class(); to validate it) and redirect them to

$username/index.php

 

$_GET and $_POST are used to get data that was passed via forms.

More links of potential interest:

 

All of these look like they explain it fairly decently:

 

http://www.w3schools.com/php/php_get.asp

http://www.w3schools.com/php/php_post.asp

http://www.tizag.com/phpT/postget.php

 

Bleh... this one looks halfway decent too:

http://www.freewebmasterhelp.com/tutorials/php/6

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.