0

This is my html form and below this i included my php text.

But I am not getting correct output,i don't no where the problem is ?

I also included the output ,please suggest me what shuld i do?

<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form  action="text.php" method="post">
What is ur name ?

<input  type="text" name="data" />


<input type="submit" value="send" />
</form>
</body>
</html>

This is my php text:

<html>
<head>
<title>
Reading data from textfields
</title>
</head>
<body>
<h1>
reading data from text field
</h1>
Thanks for answering,
<?php echo $_POST["data"];?>
</body>
</html>

Output:

reading data from text field
Thanks for answering, 

problem is that ,data send is not included after response of sever please help me as fast as possible

10
  • 1
    Can you print what you get with print_r($_REQUEST) in text.php? Commented Feb 27, 2011 at 14:12
  • i am soory ,will you please explain a little more Commented Feb 27, 2011 at 14:16
  • I am new in php ,please help me Commented Feb 27, 2011 at 14:18
  • That's exactly what @amitchd is trying to do. Please, as he asked, post the resulting output from print_r($_REQUEST) in text.php =) Commented Feb 27, 2011 at 14:22
  • 1
    If you create a text file info.php which only content is <?php phpinfo(); ?> do you get any output? Commented Feb 27, 2011 at 14:33

2 Answers 2

2

I can only speak for my own experience, but this works on my server. I'd suggest, then, that one of the following is true:

  1. Your server isn't set up to handle php (though this would surprise me), also, as @gAMBOOKa noted (in the comments), if your server's not set up to handle php the script wouldn't output anything other than the raw text-contents of the php script, literally "<?php echo $_POST["data"];?>".
  2. You're trying to access the pages through the filesystem (file:///path/to/file.html), rather than through your server (http://localhost/file.html).

If '2' is correct, move your web-page and php script into a directory within your server's document root, on *nix this could be something like /var/www/directoryName/ and access the page via http://localhost/directoryName/dataEntryForm.html. If you're on Windows, with IIS it could be C:\inetPub\directoryName\ accessed, as above, with http://localhost/directoryName/dataEntryForm.html.

Incidentally, please forgive me for not linking to a demo of the page running, it's just that I'd prefer not to run the risk of exposing my server to, presumably, vulnerable scripts.

Sign up to request clarification or add additional context in comments.

15 Comments

If the web server is not configured for php, shouldn't it output <?php echo $_POST["data"];?> ?
@gAMBOOKa: yeah, it really should, but I use '[not] set up to handle php' as a euphemism for, among other things, 'not set up properly.' Also, I didn't think of that... edited in, and my thanks! =)
@gAMBOOKa : he will only see it if he tries to view the page source. In the rendered page, it'll be invisible.
@JB: Why would it be invisible? To the browser, it's just plaintext.
@fariz, the price you pay for assistance from Stackoverflow is contributing back to the community =) I'd suggest posting that comment as an answer detailing exactly what you did to resolve your problem. Up-voting any answers that were helpful to you. Also, it's just 'David' (or, preferably, '@David'), the 'sir' is appreciated, but unnecessary =)
|
0

Your full code is like this and I tested it, working perfectly.

<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form  action="text.php" method="post">
What is ur name ?

<input  type="text" name="data" />


<input type="submit" value="send" name="btn_save" />
</form>
</body>
</html>

text.php

<?php
if(isset($_POST['btn_save']))
{


         $data=$_POST['data'];
}
?>

<html>
<head>
<title>
Reading data from textfields
</title>
</head>
<body>
<h1>
reading data from text field
</h1>
Thanks for answering,
<?php echo $_POST["data"];?>
</body>
</html>

working perfectly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.