Jump to content

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:

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

Imane
Link to comment
https://forums.phpfreaks.com/topic/14408-simple-php-question/
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
https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56923
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
https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-56929
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.

Ken
Link to comment
https://forums.phpfreaks.com/topic/14408-simple-php-question/#findComment-57587
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.

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