1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

php script from a browser

Discussion in 'PHP' started by mike_ledis, Feb 9, 2011.

  1. mike_ledis

    mike_ledis New Member

    Joined:
    Aug 3, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hello! Suppose that a php script exists in a server and i have access as a client.that script has 4 args first and second are char args third and forth are int args. If i want to run that script from my browser what syntax i have to use?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,293
    Likes Received:
    365
    Trophy Points:
    83
    PHP scripts are run directly using the browser URLs
     
  3. pein87

    pein87 New Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    0
    Occupation:
    Web Dev
    Location:
    Limbo
    You need to know the url variables. If you know that you can then add values to them. Example url

    Code:
    http://www.mysite.coom/index.php[COLOR="DarkRed"]?uid=0000001&sid=1[/COLOR]
    after the php you need a question mark or ? . This can also be done with a html page to or pretty much any script file.Then the url variable follow by an equal sign or = . This says make this url GET variable have the value after the equal sign. If there is more then one url variable you need to add an and sign or &. You can also use & but most servers have it as & . The above url has two variables that will be sent to the script via GET. POST types aren't sent so they can be seen via the url. You'd need packet filtering for that. However most use REQUEST in php so it doesn't need to filter request types. Also php doesn't use strong type, they are more or less validating the data being passed as int and string because php does not support types unless your type casting.

    the variables would be retrieved like so

    PHP:
    $user $_GET['uid'];
    $session $_GET['sid'];
    or

    PHP:
    $user$_REQUEST['uid'];
    $session $_REQUEST['sid'];
    lots of sites dont validate their GET data and sql injections happen.
     
  4. mike_ledis

    mike_ledis New Member

    Joined:
    Aug 3, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Pein87 first of all thank you! Could you explain me more about post method? If my script uses a post method how can i change the variables. I tried to make a post form in my pc,that uses the full url of the script that i want as an action. But every time, the browser is trying to find the url in the root directory that i placed my script.//ex C:/Users/mikeb/Desktop/
     
  5. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    For post Requests you have to make a HTTP request to the server page...
    Another way of doing it is to simply make a simple form like :-

    You can do this by using Firebug a great addon for mozilla

    HTML:
    <form action="page_where_you_want_to_post" method="POST">
    <input name="argument1" type="text"/>
    <input name="argument2" type="text"/>
    <input name="argument3" type="text"/>
    </form>
    
     

Share This Page