Method POST

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sheila Jipping
    New Member
    • Jan 2012
    • 18

    Method POST

    I am working thru the book PHP, MySQL and Apache from the Sams teach yourself library. On page 202 the exercise it to create an HTML input screen and then pass the variables to php. When I try my it opens my PHP listing but does not display it as a website. Any help would be appreciated.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how do you open it?

    Comment

    • Sheila Jipping
      New Member
      • Jan 2012
      • 18

      #3
      Dormilich this is the line of code in the html form form action="send_si mpleform.php" method="POST". What happens next then it that the .php file is opened for editing instead of being the web page parroting what was written the html form.

      I went to the book CD to copy the code from there thinking maybe I had a typing error that I wasn't seeing. Those files work the same as mine.

      Suggestions?!

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        are you calling the file via http & localhost?

        Comment

        • Sheila Jipping
          New Member
          • Jan 2012
          • 18

          #5
          this is the line from the html page which "calls" the php code.

          <form action="send_si mpleform.php" method=post>

          all pages are being displayed in the localhost server. I am using Apache for this.

          If I change the entire process to be just one php text file with php code list on the top with the html code listed below with this command <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"> in the html the process works.

          So I am thinking it is something to do with the act of existing one file to go to another one. It is finding the called file just isn't running it. Any suggestions????

          <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            but in general, .php files are behaving as expected?

            Comment

            • Sheila Jipping
              New Member
              • Jan 2012
              • 18

              #7
              yes they are. My problem started when I tried to send variables from a Html page to a php page.

              These are my first attempts at using this technology. I am just working through excerises in a book to learn. Everything has worked thus far with the exception of branching out from a html to php. My thoughts are at this time that being able to do this branching would prove very powerful and useful.

              thanks in advance for your response and help.

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                maybe it's time to look at your code. usually there is no problem in calling PHP scripts from HTML (and to be precise, every web page, be it created by PHP or any other server script, ends up as HTML).

                Comment

                • Sheila Jipping
                  New Member
                  • Jan 2012
                  • 18

                  #9
                  here is the code (from the book examples....)

                  Code:
                  <html>
                  <head>
                  <title>A simple HTML form</title>
                  </head>
                  <body>
                  <form action="send_simpleform.php" method="POST">
                  <p><strong>Name:</strong><br/>
                  <input type="text" name="user"></p>
                  <p><strong>Message:</strong><br/>
                  <textarea name="message" rows="5" cols="40"/></textarea></p>
                  <p><input type="submit" value="send"/></p>
                  </form>
                  </body>
                  </html>
                  Code:
                  <?php
                  echo "<p>Welcome <b>".$_POST["user"]."</b>!</p>";
                  echo "<p>Your message is:<br/><b>".$_POST["message"]."</b></p>";
                  ?>
                  and again the html page does open the php file but it is not displaying as a page but opens it for editing the php file.

                  thanks!
                  Last edited by Dormilich; Jan 23 '12, 03:27 PM. Reason: please use [CODE] [/CODE] tags when posting code

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    which browser do you use?

                    Comment

                    • Sheila Jipping
                      New Member
                      • Jan 2012
                      • 18

                      #11
                      internet explorer - apache server set as localhost

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        try Firefox or Chrome. I'm not trusting IE here.

                        Comment

                        • Sheila Jipping
                          New Member
                          • Jan 2012
                          • 18

                          #13
                          I really need it to work in Internet Explorer. I don't have the other browsers.

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            #14
                            it would help to know whether the problem is server-side or IE.

                            Comment

                            • Sheila Jipping
                              New Member
                              • Jan 2012
                              • 18

                              #15
                              Sadly, the exact same thing happens in Chrome....inste ad of running the PHP code it opens the code in a text editor (note pad).

                              Comment

                              Working...