My Browser gives back my php code instead of form inputs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cognition
    New Member
    • May 2013
    • 16

    My Browser gives back my php code instead of form inputs

    Hi guys, can anyone help?
    I use Windows 7, I installed Apache, php, MySQL and phpMyAdmin all tested OK, but my Browser give me back the same php code in my (.php) file instead of form inputs. Can any one help?
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    You need to post your code, so we can see what is wrong.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      How are you accessing your page? You have to access it through the server's port. You can't just open the file.

      Comment

      • cognition
        New Member
        • May 2013
        • 16

        #4
        here is my code:
        Code:
        <?php
        $dbc = mysqli_connect ('localhost', 'servername', 'password', 'aliendatabase') or die('Error connection to MySQL server.');
        
        	$query = "INSERT INTO aliens_abduction (first_name, last_name, email, when_it_happened, how_long, how_many, alien_description, " ."'what_they_did, fang_spotted, what_you_want, message) " ."VALUES ('Sally', 'Jones', 'tubext@msn.com', '3 days ago', '1 day', 'Four', " ."'Green with six tentacles', 'We just talked and played with a dog', 'Yes', 'Lodging Compliant', 'I may have seen your dog Contact me.')";    
        
        $result = mysqli_query($dbc, $query) or die('Error querying database.');
        mysqli_close($dbc);
        ?>
        @Rabbit - Can you pls give such description as accessing it through the server, because I after i filled the form and click the submit button, I still get this code?
        Last edited by Rabbit; May 18 '13, 06:29 PM. Reason: Please use code tags when posting code.

        Comment

        • cognition
          New Member
          • May 2013
          • 16

          #5
          @Oralloy - can you see the code?

          Comment

          • cognition
            New Member
            • May 2013
            • 16

            #6
            here also is the html form post other:
            Code:
            ...
            ...
            <form method="post" action="reportdb.php">
            <fieldset id="contact">
              <legend>Contact us</legend>
            ...
            ...
            Last edited by Rabbit; May 18 '13, 06:29 PM. Reason: Please use code tags when posting code.

            Comment

            • cognition
              New Member
              • May 2013
              • 16

              #7
              OK, this is what I did recently and still it did not work, I added this:

              Code:
              #PHPIniDir "C:/Apache/PHP/"
              LoadModule php5_module "C:/Apache/PHP/php5apache2_4.dll"
              AddHandler application/x-httpd-php .php
              
              # configure the path to php.ini
              PHPIniDir "C:/Apache/php"
              to my Apache "httpd.conf file and got this response after restarting my Apache server "The requested operation has failed!" any other clues?
              Last edited by Rabbit; May 18 '13, 06:29 PM. Reason: Please use code tags when posting code.

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                Please use code tags when posting code.

                By accessing it through the server, I mean something like this:
                Code:
                http://www.website.com/
                If you're opening the website just by double clicking the file, that doesn't open it through the server, and it's not going to process the PHP that you're sending your form to.

                Comment

                • cognition
                  New Member
                  • May 2013
                  • 16

                  #9
                  since i am not using a website such as (www.example.com) I am accessing it from my localhost server, as in :(file:///D:/My%20Websites/alien_abduction/alienabduct.htm l) in my browser, then after filling the form, I will click Submit instead of a confirmation page of data i entered in the form in I'll rather get : <?php
                  $dbc = mysqli_connect ('localhost', 'servername', 'password', 'aliendatabase' ) or die('Error connection to MySQL server.');
                  $query = "INSERT INTO aliens_abductio n (first_name, last_name, email, when_it_happene d, how_long, how_many, alien_descripti on, 'what_they_did, fang_spotted) " ."VALUES ('Sally', 'Jones', 'user@domain.co m', '3 days ago', '1 day', 'Four', 'Green with six tentacles', 'We just talked and played with a dog', 'Yes'.')";
                  $result = mysqli_query($d bc, $query) or die('Error querying database.');
                  mysqli_close($d bc);
                  ?>

                  in this location : file:///D:/My%20Websites/alien_abduction/reportdb.php

                  Comment

                  • cognition
                    New Member
                    • May 2013
                    • 16

                    #10
                    @Rabbit - sorry, except if I am violating the rules, I'd like to sound raw, to get easy help. I am working on a personal project and needed help as soon as I can. thank you for your understanding.

                    Comment

                    • Rabbit
                      Recognized Expert MVP
                      • Jan 2007
                      • 12517

                      #11
                      Using this:
                      file:///D:/My%20Websites/alien_abduction/alienabduct.htm l
                      will not work.

                      That does not access it through the server. You need to access it through your server. If the server is on the same computer that you're using, you can use localhost. If it's not on the same computer but it's on the same LAN, you can use the IP address.

                      Comment

                      • cognition
                        New Member
                        • May 2013
                        • 16

                        #12
                        Hhmm! interesting!! @Rabbit - I appreciate your patience, sure, it is on the same computer, but, can you pls be little more specific, how do i apply "viewing it through localhost" I mean steps to get this done.
                        Thank you once again,

                        Comment

                        • cognition
                          New Member
                          • May 2013
                          • 16

                          #13
                          @Rabbit - this is what I did recently, i used this: http://127.0.0.1/path/domain.html . the page displayed well, but when i filled the form and click on submit, this is what i get as a feedback in new page: "Error Code 500 (Internal Server Error)" without the quote. I explicitly understand it is an internal error, but how do i specifically fix this?

                          Comment

                          • cognition
                            New Member
                            • May 2013
                            • 16

                            #14
                            and if i use this http://www.website.com , this is the error i get below:

                            Error: Host Not Accessible
                            The web host www.alienabduct.html is not accessible.
                            Possible sources of this error:
                            The host name is invalid
                            There was a DNS error
                            The web site may be unavailable
                            You may not be connected to the internet
                            Please edit the URL, or search for it using Google.
                            Google Web Accelerator version 0.2.70.88-pintail.a
                            Windows 6.1

                            Comment

                            • Rabbit
                              Recognized Expert MVP
                              • Jan 2007
                              • 12517

                              #15
                              You'll need to check your server logs to figure out what your server error is.

                              You can't access your website through that domain unless you've actually set it up. From what I can tell from your earlier posts, you don't have one set up. So you won't be able to access it that way.

                              Comment

                              Working...