0

Hello guys,

I have a simple form with 2 input fields (name, age). On submit the values should be sent to the php file where I print them. The problem is that on submit the php file is not rendered - IE just shows me the php code, Mozilla doesn't show anything.

I've recently installed wampserver2.0i and tested phpinfo() and it works ok. I've also uploaded my files on a real server and everything works good. I think it's a problem on configuration of Apache, but I've done all the things suggested on other sites and the problem is still there.

Do you have any idea how to resolve it ?

5
Contributors
12
Replies
13
Views
7 Years
Discussion Span
Last Post by Froger93
Featured Replies
  • might not be your server setting, cos your code looks ok. i think you should check where you are running your script from your server might not recognize it as the localhost directory Read More

0

Here is the html with the form:

<html>
<body>

<form action="welcome.php" method="post" >
    Name: <input type="text" name="fname" />
    Age: <input type="text" name="age" />
    <input type="submit" />
</form>

</body>
</html>

and here it is the PHP file:

<?php
 echo 'Welcome'.$_POST["fname"].' ';
 echo 'You are'.$_POST["age"].' years old.';
?>
1

might not be your server setting, cos your code looks ok. i think you should check where you are running your script from your server might not recognize it as the localhost directory

0

You are right kaion, thank you. My files are located in "C:\wamp\www" and the server doesn't recognize this as my localhost directory.

How can I make him recognize it ? I've checked the httpd.conf and the DocumentRoot is set to this folder.

0

Thats bizare, the C:/wamp/www/ is the server root. Hmmmm.... Strange if you can render the phpinfo page then PHP should be configured. Are you sure the PHP document is name as welcome.php and not welcome.php.txt as allot of people have mistaken this for?

0

try using 'id' attribute in the textfields.make sure your html page and another php file are in the same directory.if not make the proper file path changes in action.
also this thing can be done in the same page, if you save the html page as .php and put your php code in it, like -

if(isset($_POST['submit_btn_name']) )
{
//your code here
}
0

Froger93: yes, welcome is a .php file as it says to the file properties
(If I try to echo something in the php file it prints, but sending data from the html file doesn't work )

network18: the html and php page are in the same folder "C:\wamp\www" and I've used the id attribute in the textfields but it didn't work. I've tried the method you said - putting the php file and html in the same page and it worked, but this means that all the time I will have to put html and php code in one file... (these are just some simple test files, but I have another ones with database operations that worked before reinstalling wampserver).

any more ideas what could be wrong?

Edited by DaraPsy: n/a

0

look into your apache's httpd.conf file, check and see if you have this there
DocumentRoot "c:/wamp/www/"
cos this is suppose to point it to the server

0

Yes kaion, the DocumentRoot is "c:/wamp/www/" as I've already told you.

0

The "solution" is to test my file in browser always like this : "http://localhost/SignUp.html" , but testing "file:///C:/wamp/www/SignUp.html" still doesn't work ( because, as kaion said, the server doesn't recognize the local directory ).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.