Page 1 of 1

An HTML form that calls itself. Why isnt it working?

Posted: Thu Oct 14, 2010 11:17 pm
by zeusra
Ok I am trying to get an HTML form to call itself as part of a larger project. The interesting thing is why would " method='POST'> by shown in the browser when I clearly have it within the " > " ending. I bolded the part below that is showing up in the browser when it shouldn't be. Any ideas why?

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<meta name="author" content="drewman" />

	<title>Numgen game</title>
</head>

<body>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>[b]" method='POST'>[/b]
<p>Type your guess here:</p>
<input type="text" name="guess" />
<input type="submit" value="submit your guess" />
</form>


</body>
</html>

Re: An HTML form that calls itself. Why isnt it working?

Posted: Fri Oct 15, 2010 12:19 am
by requinix
Pro Debugging Tip #1: Learn to use your browser's View Source command.

What is the HTML source of the page?

Re: An HTML form that calls itself. Why isnt it working?

Posted: Fri Oct 15, 2010 12:51 am
by cpetercarter
What is this

Code: Select all

<span style="font-weight: bold">
doing in the middle of a form tag? I think you have misplaced it, and that the confusion of quotation marks which it places in the form tag is the cause of your problem,

Re: An HTML form that calls itself. Why isnt it working?

Posted: Fri Oct 15, 2010 8:11 am
by requinix
The post had tags around the method=POST part, which expand to <span> tags. Ben must not have seen that when he edited the post.
So it's a problem with the post's code, not the real code. Quote the post and check it out.

Re: An HTML form that calls itself. Why isnt it working?

Posted: Fri Oct 15, 2010 10:32 am
by VladSun
You're vulnerable to XSS attacks - don't use PHP_SELF.