开发者

html form-php question

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜