473,383 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

My Browser gives back my php code instead of form inputs

cognition
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?
May 17 '13 #1
22 2931
Oralloy
987 Expert 512MB
You need to post your code, so we can see what is wrong.
May 17 '13 #2
Rabbit
12,516 Expert Mod 8TB
How are you accessing your page? You have to access it through the server's port. You can't just open the file.
May 17 '13 #3
here is my code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dbc = mysqli_connect ('localhost', 'servername', 'password', 'aliendatabase') or die('Error connection to MySQL server.');
  3.  
  4.     $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.')";    
  5.  
  6. $result = mysqli_query($dbc, $query) or die('Error querying database.');
  7. mysqli_close($dbc);
  8. ?>
@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?
May 18 '13 #4
@Oralloy - can you see the code?
May 18 '13 #5
here also is the html form post other:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. ...
  3. <form method="post" action="reportdb.php">
  4. <fieldset id="contact">
  5.   <legend>Contact us</legend>
  6. ...
  7. ...
May 18 '13 #6
OK, this is what I did recently and still it did not work, I added this:

Expand|Select|Wrap|Line Numbers
  1. #PHPIniDir "C:/Apache/PHP/"
  2. LoadModule php5_module "C:/Apache/PHP/php5apache2_4.dll"
  3. AddHandler application/x-httpd-php .php
  4.  
  5. # configure the path to php.ini
  6. 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?
May 18 '13 #7
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

By accessing it through the server, I mean something like this:
Expand|Select|Wrap|Line Numbers
  1. 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.
May 18 '13 #8
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.html) 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_abduction (first_name, last_name, email, when_it_happened, how_long, how_many, alien_description, 'what_they_did, fang_spotted) " ."VALUES ('Sally', 'Jones', 'user@domain.com', '3 days ago', '1 day', 'Four', 'Green with six tentacles', 'We just talked and played with a dog', 'Yes'.')";
$result = mysqli_query($dbc, $query) or die('Error querying database.');
mysqli_close($dbc);
?>

in this location : file:///D:/My%20Websites/alien_abduction/reportdb.php
May 19 '13 #9
@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.
May 19 '13 #10
Rabbit
12,516 Expert Mod 8TB
Using this:
file:///D:/My%20Websites/alien_abduction/alienabduct.html
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.
May 19 '13 #11
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,
May 20 '13 #12
@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?
May 20 '13 #13
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
May 20 '13 #14
Rabbit
12,516 Expert Mod 8TB
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.
May 20 '13 #15
Oralloy
987 Expert 512MB
Cognition,

Sorry for being so long in reply, I've been busy doing my weekend.

I'm so glad Rabbit spotted your problem from the outset. I wouldn't have suspected you weren't running your page through a server when you were looking at it.

Are you running a web server with PHP on your computer? If not, you'll need to understand and install the appropriate software before you can even start to develop pages.

BTW, it's nice to see someone working on a project to improve themselves.

Good luck!
Oralloy
May 20 '13 #16
@Orally, welcome back, I understand all that you said and I want to assure you that all my test pages for Apache, PHP, MySQL and phpMyAdmin was successful after each installation, isn't that a possible way to be sure that my installation and configurations of each was OK?

I have reviewed each "httpd.conf, php.ini and config.inc.php" configuration settings several times, made necessary adjustment and as well as restarting my Apache server at different interval turned out well, my project site is completely done, but what is holding me back right now is the contact form page. I really want this form to be more secured and that is why I have been trying to do this configurations with virtual machines a I aboded above. the codes and tags that i posted earlier are just form test page to see if customer/client inputed data when in my project site can return to my database instead of emails. I created a database in SQL server and a table inside the database to store filled data from the site contact form, and the form inputed data are not coming into the database table.

I will appreciate more help.

Thank you,

Cognition
May 20 '13 #17
@Rabbit - Do you mean, I need to register a domain name, and I needed an internet connection each time I'm working on my localhost server?

Sorry for my dump questions and thanks for you patience, but, I think, you can try to be more comprehensive in your response to me.

Waiting to hear from you again,

Thanks,

Congnition
May 20 '13 #18
does the below make sense to you guys? is that the log? i altered on the token and data basename and table.

Expand|Select|Wrap|Line Numbers
  1. 127.0.0.1 - - [20/May/2013:14:58:28 +0100] "GET /phpmyadmin/js/messages.php?lang=en_GB&db=prodatabase&token=cdc0ae7492ee487da85 HTTP/1.1" 200 16647
  2. 127.0.0.1 - - [20/May/2013:14:58:28 +0100] "GET /phpmyadmin/js/get_image.js.php?theme=xxhomme HTTP/1.1" 200 6263
  3. 127.0.0.1 - - [20/May/2013:14:58:28 +0100] "GET /phpmyadmin/index.php?db=prodatabase&table=pro_name&server=1&target=tbl_sql.php&token=cdc0ae7492ee487da85 HTTP/1.1" 200 20077
  4. 127.0.0.1 - - [20/May/2013:14:58:29 +0100] "GET /phpmyadmin/js/get_image.js.php?theme=pmahomme HTTP/1.1" 200 6263
  5. 127.0.0.1 - - [20/May/2013:14:58:29 +0100] "GET /phpmyadmin/js/messages.php?lang=en_GB&db=prodatabase&token=cdc0ae7492ee487da85 HTTP/1.1" 200 16647
  6. 127.0.0.1 - - [20/May/2013:14:58:29 +0100] "GET /phpmyadmin/index.php?ajax_request=1&recent_table=1&token=cdc0ae7492ee487da85 HTTP/1.1" 304 -
  7. 127.0.0.1 - - [20/May/2013:14:58:31 +0100] "POST /phpmyadmin/import.php HTTP/1.1" 200 17843
  8. 127.0.0.1 - - [20/May/2013:15:05:12 +0100] "GET / HTTP/1.1" 200 3214
  9. 127.0.0.1 - - [20/May/2013:15:05:12 +0100] "GET /icons/blank.gif HTTP/1.1" 200 148
  10. 127.0.0.1 - - [20/May/2013:15:05:12 +0100] "GET /icons/folder.gif HTTP/1.1" 200 225
  11. 127.0.0.1 - - [20/May/2013:15:05:12 +0100] "GET /icons/text.gif HTTP/1.1" 200 229
  12. 127.0.0.1 - - [20/May/2013:15:05:12 +0100] "GET /icons/image2.gif HTTP/1.1" 200 309
  13. 127.0.0.1 - - [20/May/2013:15:05:12 +0100] "GET /icons/unknown.gif HTTP/1.1" 200 245
  14. 127.0.0.1 - - [20/May/2013:15:05:13 +0100] "GET /favicon.ico HTTP/1.1" 404 283
  15. 127.0.0.1 - - [20/May/2013:15:06:04 +0100] "GET / HTTP/1.1" 200 48
  16. 127.0.0.1 - - [20/May/2013:15:06:05 +0100] "GET /favicon.ico HTTP/1.1" 404 283
  17.  
  18. ============================
  19. [Mon May 20 15:31:37 2013] [notice] Parent: Received restart signal -- Restarting the server.
  20. [Mon May 20 15:31:37 2013] [notice] Child 9016: Exit event signaled. Child process is ending.
  21. [Mon May 20 15:31:37 2013] [notice] Apache/2.0.64 (Win32) configured -- resuming normal operations
  22. [Mon May 20 15:31:37 2013] [notice] Server built: Oct 18 2010 01:36:23
  23. [Mon May 20 15:31:37 2013] [notice] Parent: Created child process 9104
  24. [Mon May 20 15:31:37 2013] [notice] Child 9104: Child process is running
  25. [Mon May 20 15:31:38 2013] [notice] Child 9104: Acquired the start mutex.
  26. [Mon May 20 15:31:38 2013] [notice] Child 9104: Starting 250 worker threads.
  27. [Mon May 20 15:31:38 2013] [notice] Child 9016: Released the start mutex
  28. [Mon May 20 15:31:39 2013] [notice] Child 9016: All worker threads have exited.
  29. [Mon May 20 15:31:39 2013] [notice] Child 9016: Child process is exiting
May 20 '13 #19
Rabbit
12,516 Expert Mod 8TB
I'm not saying you need to set up your domain. I'm saying if you're going to try to access it through the domain then you will need to set it up. But it's not necessary to access it through the domain as you already have accessed it through the localhost.

That looks like a log of some sort. Whether it's the right one I do not know. You'll have to look through it to see if you can find the internal server error you got earlier.
May 20 '13 #20
Oralloy
987 Expert 512MB
cognition,

Your server tests and MySQL Admin run correctly, however are you able to run a simple PHP script that generates a trivial, but obviously computed page (for example, compute 2+2, and display it in the HTML)?

I may be way off base, but it seems to me that your site is static, except for this single PHP page.

Still, this is starting to sound like an apache configuration issue. Have you got PHP configured for your target site's domain in httpd.conf? Also, you might want to review your .htaccess files for the site you're developing, just to make sure that PHP is not overriden. I am writing from a basis of experience; I have not recently configured a bare apache system to run PHP.

Also, there is nothing wrong with editing the hosts file on your development system to point your target domain name at the server IP you're developing on. This is the method that I use to sandbox my development efforts. The file format is very simple, basically IP-address space System-name. For example, this is what I would add to work against client code for DMAT.com:
Expand|Select|Wrap|Line Numbers
  1. ##
  2. ##  DMAT.com test implementation
  3. ##
  4. 127.0.0.1 dmat.com
  5. 127.0.0.1 www.dmat.com
  6.  
Then, after I deploy, I can comment out the redirection, and use normal DNS for my live testing.

Hopefuly this helps some.

Cheers!
Oralloy
May 20 '13 #21
Thanks for your concern guys, I'll take a time off, just one day will do to cool my relax my neuron a bit, then, I will come back cracking this logic. I appreciate all your efforts and I am going to come back with more details, whether I am able to solve it or not.

Thanks once gain,

Cognition
May 20 '13 #22
@Oralloy & Rabbit, Hi, thank you guys for last time, i was able to solve my problem with you help, please check, i posted a new issue.

Thank you.

Cognition
Jun 10 '13 #23

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Tony Marston | last post by:
If the use of the browser's BACK button is interfering with the operation of your web application then take a look at this article entitle "Back Button Blues" ...
3
by: Ray Torres | last post by:
I would appreciate any help with the following problem. I have several different htm pages with (simalar) forms that are processed by the same PHP script. If there is data missing on the form,...
9
by: jcnews | last post by:
When designing a webpage, is there a way to disable the back button? It must be possible. I am asking because there are certain web applications that I have used that require the user to...
2
by: Luboą ©lapák | last post by:
Hi, I need (in one function in aspx page) return the WWW browser back to previous page. How can I do it? Thanks
3
by: A.M | last post by:
Hi, When I call FormsAuthentication.SignOut(); the user is not authenticated anymore, but if user clicks on browser's Back button, all previously viewed pages are viewable. How can I prevent...
0
by: Robert Kent via .NET 247 | last post by:
I have a form that Response.Redirect's to itself. I have Page.SmartNavigation = false. But when I hit the browser's back button it doesn't go back to the previous instance of the form, which doesn't...
3
by: Rosanne | last post by:
Is there a way to clear the SelectedIndex of a listbox when the browser's back button is clicked? I have a page that contains a server side list box with AutoPostBack = True. When the user...
3
by: Etantonio | last post by:
Good morning, I have a static html page where I want to load image that day to day are in a different path, to achieve this I would want that the link point to a c# page where I create...
10
by: mjahabarsadiq | last post by:
I would like to reload the page when it is redirected by the browser's Back or Forward button. I tried the following but it does not works. <link rel="prev" href="url"> <link rel="next"...
3
by: Dipti Singh | last post by:
Hi All, Please help me, I am trying it from 2 days. I have a login page in asp that is including other pages using #include..... after login user in the same page but enters in the database. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.