0

I was learning to validate form data. When I had to write this:

"<"form method="post" action=""<"php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"

but when I write this, in output, there is a "> showing at the top of the page. Why?

4
  • When you have a problem with what the browser is rendering, look first at the HTML — not the PHP which generates it — and use a markup validator. Commented Sep 2, 2014 at 6:31
  • here is my full html file: Commented Sep 2, 2014 at 6:33
  • <html> <body> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name"> E-mail: <input type="text" name="email"> Website: <input type="text" name="website"> Comment: <textarea name="comment" rows="5" cols="40"></textarea> Gender: <input type="radio" name="gender" value="female">Female <input type="radio" name="gender" value="male">Male </form> </body> </html> Commented Sep 2, 2014 at 6:35
  • @RedwanulSourav use that HTML as your PHP code and you will be fine. Commented Sep 2, 2014 at 6:46

1 Answer 1

1

Assuming, there is an echo or a print.Change this:

echo "form method="post" action=""<"php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"

to this:

echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.