Jump to content

Submitting a form without any Method?


doomed2020

Recommended Posts

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

 


<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

 


$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

Link to comment
Share on other sites

1. Forms always have methods. It is not possible for them to not have one. If you don't specify one then it is GET by default.

 

2. Make your process.php check that the form('s fields) were submitted using whatever method it wants. For a login form you must use POST - otherwise, with GET, the credentials will show up in the URL and that's Bad.

if (empty($_POST["userName"]) || empty($_POST["pass"])) {
    // form was not submitted properly
    // do something, like redirect or show a login form with error or whatever
} else {
    // form was submitted properly
}

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.