Adding to .php

burner35

New Member
Messages
127
Reaction score
0
Points
0
Hello all Web developers,

I am wanting to know how to add things to .php

i.e:
.php?action=yourprofile

Does anyone know how to add this/Create this?

Thanks

-burner35
 

burner35

New Member
Messages
127
Reaction score
0
Points
0
I have no idea, I just want to know how to add that sorta stuff.
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Well, if you're using a form with method GET, the data that's entered is added to the query string. For example:
HTML:
<form action="form.php" method="post">
<input type="text" value="value1" name="input1" />
<input type="text" value="value2" name="input2" />
<input type="submit" value="submit" />
</form>
If you press the submit-button (without changing the values), the user would get referred to form.php?input1=value1&input2=value2

Of course, instead of using a form to add the query string, you can also use links with query strings or just type it in the address bar of your browser...

The use of these query strings is like this:
if you've got the above example (form.php?input1=value1&input2=value2), you can access the values of input1 and input2 in php: $_GET['input1'] and $_GET['input2'].

Note: method GET is not really secure, as you can see what you typed in in the address bar of your browser... don't try to send passwords with this... use method POST instead.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
I think I know what you mean.

You want your site index to open a specified file if called upon. Like on forums, (smf for example):

http://somesite.com/forums/index.php?action=pm

that brings the user to the private message system of the forum. There is a simple, secure way to do this.

PHP:
<?php

if (isset($_GET[action]) && file_exists($_GET[action].".php"))
{

    $allowedpages = array("userprofile", "addyours");
                             
          //add new pages by doing ' , "name" ' without the ' '

    if (in_array($_GET[action],$allowedpages))
    {

        include($_GET[action].".php");

    }
    else
    {

        die("Hacking attempt");

    }

}
else
{

    include("idx.php");

}

?>

what you would do is rename your current index.php to idx.php

and make another index.php with this code.

if you have any questions, ask.
 
Top