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...

 

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.