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 ?

Recommended Answers

All 12 Replies

Can we see the code i think that would help.

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.';
?>

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

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.

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?

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
}

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?

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

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

So have you resolved this issue then?

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 ).

I would just install XAMPP it's easier and I have never seen this issue in XAMPP.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.