tags:

views:

30

answers:

3

I want to retrieve NAME OF FORM from php when i am submitting a form. Can i find the NAME OF FORM by PHP?

+1  A: 

No, but you can get the submit button name.

greg0ire
Or include a hidden field.
MvanGeest
A: 

Short answer: No.

Long answer: If your PHP code is inline, I don't see why you couldn't use the form name in your PHP code. However, if your PHP code resides in a separate script and you're submitting your form to that script, then you need to explicitly pass in the name of the form through an input element (a hidden input element will work).

Vivin Paliath
I have a form with no captcha and this is submitting by POST method.I am fearing for Spamming. User can spam my database by ajax. How will i protect it by Spammers.ANy idea.. thanks in advance.
Ajay
You will need to use a captcha. A determined attacker can easily go through your code and see that you're sending in the form name in a hidden field.
Vivin Paliath
+1  A: 

No, only successful controls are submitted. The name of the form is just for scripting. But you could use a hidden input to set a name for the form:

<form action="…">
    <input type="hidden" name="form-name" value="foobar">
</form>
Gumbo
I have a form with no captcha and this is submitting by POST method.I am fearing for Spamming. User can spam my database by ajax. How will i protect it by Spammers.ANy idea.. thanks in advance.
Ajay
@Ajay: That’s a completely different type of question. So you wanted the form’s name to protect yourself against spam?
Gumbo
yes exactly.. i want to protect it by form name retrieving so spammers can't get guess and send it by ajax.
Ajay
@Ajay: Knowing the form’s name does not protect you against spammers. They could easily obtain the form’s name and send it along with the request.
Gumbo