Jump to content

simple php question


Recommended Posts

hello everybody

I am new here and to php

I 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 explorer

the code is bellow:

<title> form 1 </title>

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


[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 format

I wonder what is the problem

I will be so greatful if you help me, this is almost the first obstacle I face in php : )

Thank you

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

thank you Chris,

I am working with easyphp, and I alreayd tried php files and they open with internet explorer very fine

The problem rose when I used a form that have an action of displaying the php file

do you think of any other reason why this happens?
Link to comment
Share on other sites

I have included the code

In fact i took it from a tutorial that I am trying to practice

They show us in the tutorial how to use forms with POST method

I took it from: http://www.php.net/manual/en/tutorial.forms.php

What 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 POST

maybe I am doing it the wrong way

help plz!
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.