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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zeusra
Forum Newbie
Posts: 6
Joined: Tue Sep 07, 2010 11:55 pm
Location: WA

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

Post 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>
Last edited by Benjamin on Fri Oct 15, 2010 12:21 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

Pro Debugging Tip #1: Learn to use your browser's View Source command.

What is the HTML source of the page?
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

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

Post 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,
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

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

Post by VladSun »

You're vulnerable to XSS attacks - don't use PHP_SELF.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply