is there any way to get a form name from a page that the post or get variables sent from ?

for example : $_POST , $_POST .. What would it be if you wanted the form name to be sent ?

Recommended Answers

All 4 Replies

HTTP doesn't transfer any information about the form, because the website generates the code itself. I believe that the tag "name" was added with JavaScript to access these field in JS.

But what do you need it for? The only thing I can imagine is one of these phishers or cookie-grappers. If you want to know how this works you better don't ask me.

nah i just want to make sure that these variables came from the form i have set up and not from someone who is trying to hack their way in ... just another security measurement in a login form

I am not sure if its possible in Php. But its definitely possible in javascript.

<html>
<head>
<script type="text/javascript">
function getformname(form) {
	alert(form.name);
	return false;
}
</script>
</head>
<body>
<form name="test" action="test.php" method="post" onsubmit="javascript: return getformname(this);">
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Cheers,
Nav

then why don't you vary the names of the textfields? Eg

name="name<?echo date("Y-m-d")?>"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.