SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation What if Form Method was empty when submitted?

    Hi there,

    If a form was submitted without any proper method , how can we grab that particular information on the other side ?

    For example :

    index.php
    HTML Code:
    <form action="process.php" method="">
    
    Userame: <input type="text" name="userName" />
    Password: <input type="password" name="pass" />
    <input type="submit" name="submit" value="submit"
    
    </form>
    process.php
    PHP Code:

    $userName 
    $_REQUEST['userName'];
    $password $_REQUEST['pass'];

    echo (
    "Welcome " $username " to our page."); 
    Now what if a user deliberately alters the method, and uses "$_POST or $_GET or Leaves it blank. How can I can make it fool proof on the server side without using the $_REQUEST Global Variable?

    Is there any other way to grab that submitted information like in $_SERVER Global Variable ?

    *For those who think the form will not submit without disclosing the method, then they must try this after disabling their Java-script.

    I hope you understand my question and would reply me in as detail as possible.

    Thanks

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    You use $_GET or $_POST, if the form is not submitted in a way you expect then you ignore it.
    It is that easy.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2009
    Location
    South Carolina
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should program to use what you want.

    You should complete the form tag to be:
    <form action="process.php" method="post">
    if that is the method you want to use.
    Each day is a learning experience.

  4. #4
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,034
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Browsers default to post if the method is not specified.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •