cat_emma Posted July 12, 2006 Share Posted July 12, 2006 hello everybodyI am new here and to phpI want to use the POST method to display the information entered in an html form, i want to display it in a php page. but the problem is: when i submit the form, i get a box to download the php form instead of having it displayed in internet explorerthe code is bellow:[code]<html> <head> <title> form 1 </title> </head> <body> <form action="example_2-2.php" method="POST"> <P>Your name: <input type="text" name="name" /></P> <P>Your age: <input type="text" name="age" /></P> <P><input type="submit" /></P> </form> </body></html>[/code][u]php file[/u][code]Hello <?php echo $_POST['name'];?>You are <?php echo $_POST['age'];?> Years old[/code]So when I fill the form and submit, insted of getting the exmaple_2-2.php displayed, i get a box that asks me whether i want to open or download the .php file. When I choose open, I get it open in a txt formatI wonder what is the problemI will be so greatful if you help me, this is almost the first obstacle I face in php : ) Thank youImane Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/ Share on other sites More sharing options...
cmgmyr Posted July 12, 2006 Share Posted July 12, 2006 You will need to set up apache and php on your pc. If you don't do that, it will just treat php as a download. A great all-in-one package is xampp.-Chris Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56921 Share on other sites More sharing options...
Buyocat Posted July 12, 2006 Share Posted July 12, 2006 Could you be a little more explicit, what exactly is your problem? Did you change the script so that instead of evaluating the form with example#.php you use your own script? And is this new script just displaying itself as text instead of being processed? If so the problem sounds like A) the file isn't .php or B) you didnt put the code in the absolutely necessary <?php ?> tags. If I didn't address you're issue give us a little more information, it's hard to tell what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56923 Share on other sites More sharing options...
cat_emma Posted July 12, 2006 Author Share Posted July 12, 2006 thank you Chris,I am working with easyphp, and I alreayd tried php files and they open with internet explorer very fineThe problem rose when I used a form that have an action of displaying the php filedo you think of any other reason why this happens? Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56927 Share on other sites More sharing options...
cat_emma Posted July 12, 2006 Author Share Posted July 12, 2006 I have included the codeIn fact i took it from a tutorial that I am trying to practiceThey show us in the tutorial how to use forms with POST method I took it from: http://www.php.net/manual/en/tutorial.forms.phpWhat I am trying to do is: get name and age from a form and display in a php page a message that uses those parameters that I will get from the POSTmaybe I am doing it the wrong wayhelp plz! Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56929 Share on other sites More sharing options...
kenrbnsn Posted July 12, 2006 Share Posted July 12, 2006 How did you invoke your script. It must be invoked via a URL. It can't be invoked by double clicking it.Ken Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56930 Share on other sites More sharing options...
cat_emma Posted July 12, 2006 Author Share Posted July 12, 2006 I invoke it by clicking the submit button of the form.htm page (I included its code in my first posting) Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56935 Share on other sites More sharing options...
cmgmyr Posted July 12, 2006 Share Posted July 12, 2006 Did you open it up THOUGH the browser or just double clicked it in the folder that it was in? Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56937 Share on other sites More sharing options...
cat_emma Posted July 12, 2006 Author Share Posted July 12, 2006 i am putting the file in the www, so i opened the form.htm from the localhost/... Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56938 Share on other sites More sharing options...
cat_emma Posted July 13, 2006 Author Share Posted July 13, 2006 any help plz? Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57570 Share on other sites More sharing options...
ShogunWarrior Posted July 13, 2006 Share Posted July 13, 2006 Can you put this into a file called [b].htaccess[/b] in the same folder and try again:[code]AddType application/x-httpd-php .php .php3 .php4 .php5[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57573 Share on other sites More sharing options...
cat_emma Posted July 13, 2006 Author Share Posted July 13, 2006 u mean I create a file in www and name it htaccess, then put the code u gave e in it?(sorry maybe my question is stupid, but I am in the first days of php) Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57579 Share on other sites More sharing options...
ShogunWarrior Posted July 13, 2006 Share Posted July 13, 2006 No problem, it's good you're learning.Yeah put it in a file called [b].htacces[/b]. (Strange filename, it's just a prefix!)Put my code in there and then you may need to reload EasyPHP. Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57580 Share on other sites More sharing options...
cat_emma Posted July 13, 2006 Author Share Posted July 13, 2006 I found in the file written:Order deny,allowallow from 127.0.0.1deny from allso i just added the code u gave me, but i face the same problem... Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57586 Share on other sites More sharing options...
kenrbnsn Posted July 13, 2006 Share Posted July 13, 2006 The naming of files with just an extension like ".htaccess" is directly related to the convention on UNIX operating systems and their dirivitives like Linux that hides any file that starts with a period from a normal directory listing. It's a form of rudimentary security. The basic explanation of this is: these are files that "normal users" shouldn't have to play with, so if they can't see them when they do a directory listing, the don't know they are there, so they can't be fooled with.Ken Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57587 Share on other sites More sharing options...
ShogunWarrior Posted July 13, 2006 Share Posted July 13, 2006 I thought I'd have a go incase the wrong headers were being sent to download etc.Could you post the full url of the form page in the browser? Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57589 Share on other sites More sharing options...
cat_emma Posted July 13, 2006 Author Share Posted July 13, 2006 the full url of the form isC:\Program Files\EasyPHP1-8\www\form1.htm Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57645 Share on other sites More sharing options...
cat_emma Posted July 15, 2006 Author Share Posted July 15, 2006 Thanks ALLAH I found the solutionthe problem is that I used to have the form in an htm extension while it should be php so that the server treats it I guessi changed the .htm to .php and now it works: ) tnx to all who tried to help Quote Link to comment https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-58636 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.