0

I have to figure out someone's codes... When the user click submit, it will go to another page. But it seems like there's no $_post, $_get, or $_REQUEST in the file. I also tried to delete name and value in the input tag, it still works. It also still works if I delete method, name and id in the form tag...

It doesn't work if I delete the form tag.

   <form method="post" name="my_form" id="50">form content
   <input type="submit" name="val1" value="value"></input>
   </form>

After delete method, name, and id it still works:

    <form>form content
   <input type="submit"></input>
   </form>

So my question is, is there other way you know that can be used in submitting a form? Thank you for your time.

Pluto
  • 313
  • 1
  • 8
  • 19
  • Ajax? Or more specifically, JavaScript in any fashion would probably be able to do it. – karllindmark Jun 19 '13 at 22:32
  • Can you find the form name in the PHP? – phenry Jun 19 '13 at 22:33
  • The form is submitted by the ``When you submit a form, it does what it says in the form tag `method=` -- and since yours is `method=POST`, that is what makes it do the POST. – cssyphus Jun 19 '13 at 22:33
  • 1
    @gibberish, not really. If that would be his complete code then clicking on the submit button will do nothing because there's no `action` attribute. – Shoe Jun 19 '13 at 22:35
  • if register_globals is turned on, you won't need to use $_POST to access a posted variable. This is considered VERY bad practice and is actually going away from php. – Jonathan Kuhn Jun 19 '13 at 22:35
  • If you don't want to use the form's submit system to POST the data to the PHP file, then you can use AJAX, as suggested by ninetwozero above. [Here is a link](http://stackoverflow.com/questions/13734395/form-inside-of-load-not-posting-correctly/13734466#13734466) with a simple example. – cssyphus Jun 19 '13 at 22:36
  • @Jeffrey Good observation - +1 – cssyphus Jun 19 '13 at 22:36
  • 4
    @Jeffrey Actually, if you don't have an action, the form will just submit to self. Yes, if that is the complete code, nothing would happen simply because he is doing nothing with the post data. – Jonathan Kuhn Jun 19 '13 at 22:37
  • @JonathanKuhn, I'm pretty sure it just doesn't do anything. To submit to self you would do `action="#"` or `action=""`. – Shoe Jun 19 '13 at 22:38
  • 1
    @Jeffrey try it, just don't assume. – Jonathan Kuhn Jun 19 '13 at 22:39
  • @JonathanKuhn, too lazy: you win. :) – Shoe Jun 19 '13 at 22:40

4 Answers4

4

Your code is probably using an AJAX request instead of the classic form submitting method. If you notice there's no action attribute in the form HTML tag and instead there's an id attribute which can be easily used to select the item via Javascript.

For example in jQuery:

$('#50')...
Shoe
  • 74,840
  • 36
  • 166
  • 272
0

I think Jeffrey may be right. It could be using Javascript or Ajax or JQuery or some combination of these. Look for an onSubmit event function linked to the form element or possibly an onClick event function linked to the Submit input element in the Javascript section of the page. This could easily be calling a document.{formelement}.submit(). Given it isn't working, it may even be doing a window.location() call to navigate to the other page without passing any data (eugh!!!) Shooting in the dark unless we can see more of the script.

Arthur Nicoll
  • 391
  • 1
  • 2
  • 8
0

If the form still works when you remove all attributes from the form tag and you cannot find any references to $_POST, $_GET or $_REQUEST in the file(s) that get called, it is possible that register_globals is turned on (if you're not on php 5.4...).

That setting causes posted variables to be automatically converted to "normal" variables, like $val1 in your case.

If this is the case, it is highly recommended to turn it off and rewrite your code to use the "normal" super-globals (see the manual).

jeroen
  • 91,079
  • 21
  • 114
  • 132
-1

if its not in that file (and remember to check ALL includes / requires)

Then the server is re writing it. Check your apache config files.

You can tell which page the form is being submitted to by using a tool like firebug. But the look of the code is its being submitted to the page its currently on

exussum
  • 18,275
  • 8
  • 32
  • 65