0

So I have been following this tutorial here

I have installed WAMP and the server is up and running just fine. (As the green light in the taskbar indicates).

In the www folder I have the following 2 files:

        <!DOCTYPE html>
        <html>
        <head>
        <title>First Form</title>
        </head>
        <body>

             <form action="postForm.php" method="post">

             <TextArea 

                name="microBlog" id="microBlog" cols="30" rows=“10">

             </TextArea>  

             <input type="submit">          

            </form>

        </body>
        </html>

and

    <!DOCTYPE html>
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>

        <?php 

            $microBlog = $_POST['microBlog'];          
            echo $microBlog;  

        ?> 

     </body>
    </html> 

However, when I run the html file and input "hello" into the field, clicking the submit button returns a blank screen.

Here is the html screen on open:

enter image description here

and on clicking submit the following is in the address bar:

file:///C:/wamp/www/postForm.php

Any ideas why the blank screen?

Does the PHP (postForm) file require HTML tags or can I get rid of them?

5
  • Check out error log. Is there any error? Commented Jun 17, 2015 at 9:33
  • 1
    I think you have to open the html via Webbrowser localhost/yourfile.html and you opened it with your Explorer right ? Commented Jun 17, 2015 at 9:36
  • you dont need HTML Tags in the php script. It will show plain text. Commented Jun 17, 2015 at 9:38
  • Brilliant, this fixed it. I'm not sure why this is necessary though. Does the HTML file not still access the php file regardless. If you could explain this as an answer below I'd be grateful. Commented Jun 17, 2015 at 9:38
  • Hit localhost/file.php then add your text in box then submit. Commented Jun 17, 2015 at 9:38

2 Answers 2

2

Open the file via http://localhost/... The reason for the blank screen is: You can open a html-file with the explorer and it will work fine because it will be rendered by the default-web-browser. you need a parser for php-scripts. The Webserver will use this parser if you add the extension .php but if you open the file in the Explorer you don't use the Webserver (in your case apache). If you want to open the file in the explorer set the action-attribute to action="http://localhost/postForm.php" and it will work.

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

Comments

0

You should use

action="http://localhost/postForm.php" 

instead of

 action="postForm.php"

hope this help :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.