2

On clicking the submit query button, it should display the information the user has entered but it is not happening here. Where is the mistake? Here is the html code:

<html>
    <body>
        <form method="post" action="temp2.php">
            Name: <input type="text" name="name" ><br>
            E-mail: <input type="text" name="e-mail" ><br>
            <input type="submit" >
        </form>
    </body>
</html>`

And the temp2.php file:

<html>
    <body>
        Name: <?php echo $_POST["name"]; ?><br>
        E-mail: <?php echo  $_POST["e-mail"]; ?><br>
    </body>
</html>

This is the image of the output when Submit button is clicked.

17
  • this should work. what's showing and what's not showing? errors if any? running this from your own machine? is a webserver/PHP installed? the list goes on... and hoping comments don't go unseen here. Commented Nov 1, 2015 at 14:01
  • I have added an image of the output that I'm getting. I have xampp installed and running if it matters in this case. Commented Nov 1, 2015 at 14:05
  • make sure it's properly installed then. check for errors. Commented Nov 1, 2015 at 14:05
  • Try using email instead of e-mail. Else put a <?php print_r($_POST); ?> to see all sent post-data. Commented Nov 1, 2015 at 14:06
  • @zwergmaster that shouldn't matter. hyphens only fail for variables and not POST arrays. Commented Nov 1, 2015 at 14:07

2 Answers 2

2

(now that we know what was NOT going on here)

OP:

"I had those files in php folder and not in htdocs folder. It's up and running now, thank you everyone."

Having used error reporting would have thrown you a notice about that file/folder not being found.

Something to which I pointed out very much earlier in the comments area.

Your best bet when coding is to check if a folder/file exists in the first place and inside a conditional statement.

and checking if your inputs are set/not empty:

Sign up to request clarification or add additional context in comments.

Comments

1

I tested it and it's working just fine. Make sure that your html and temp2.php files are in the same directory.

5 Comments

This really needs to be a comment instead of an answer
Do we need xampp to be running to test this?
@DeveloperX I upvoted your answer because that's what the real problem was from the start and felt you needed to know. After all the commenting back and forth, their question was unclear from the get-go.
It takes one to know one... happy coding :D
@DeveloperX :-) Cheers

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.