PHP Programming > Beginners - Learning PHP

what kind of php is there?

(1/5) > >>

ILCM:
hey guys

i just wondering what type of php coding is there? i  notice there is 2 types of php coding , one of them is like "site.com/profile.php" and the other is like "site.com/index.php?name=profile".... what is the difference between them and what are they called?

Smokey PHP:
That's exactly the same, only the second example is passing data to index.php via a "GET" request. In index.php you could do:


--- PHP Code: ---echo $_GET['name']; //this would output (in your example):profile
--- End code ---

ILCM:
ohh nice very fast answer :D ... ohh now i understand , i heard there are more security risks using $_GET method ? and i also wondering if its hard to convert the script so it use the files instead like "profile.php". ( you might be wondering what i am doing ? the thing is that i found a script that i will be modifying simple stuff to learn instead just watching videos) ....  i dont know much about php so please excuse me :'(

Smokey PHP:
Yes most people when submitting forms or any other method of transmitting data will tend to use the POST method as it is sent through the page request with no traces (to the average user). You could send the same data to a file, but using GET your URL would be:

(not so secret)

--- PHP Code: ---//URL = index.php?mysecretcode=abc123
$mycode = $_GET['mysecretcode'];
--- End code ---


(much more secret)

--- PHP Code: ---//URL = index.php
$mycode = $_POST['mysecretcode'];
--- End code ---


Of course, always clean any data from $_POST or $_GET as either set of data can be tampered with. List of useful functions for this below:


* trim() - http://uk.php.net/trim
* strip_tags() - http://uk.php.net/strip_tags
* addslashes() - http://uk.php.net/addslashes

ILCM:
the script only use $_get for public stuff like "site.com/page.php?name=picture&id=1" but while loging in it use the $_post  method , so there no risks right ? and also is it hard to convert php coding type from "page.php?name=picture&id=1" to  "site.com/picture.php" ?

Navigation

[0] Message Index

[#] Next page

Go to full version