×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Thanks. Here is the code and information.

The result now is no error, but displayed nothing after I inputted something in the name field and submitted.

//sample_register.htm
<html>
<form method="POST" action="sample_register.php" name="rname">
<p>Name:<input type="text" name="usrname" size="50" tabindex="1"></p>
<p> </p>
<p><input name=B1 type=submit value="Submit"></p>
</form>
<p> </p>
</html>

//sample_register.php
<?php
echo $_POST[usrname]
?>

PHP Version => 5.0.2
WinXP
Apache 2.0.48 (win32)
register_globals = On (although it was recommended to be off because this often leads to security bugs.)

Doesn't work either if using $usrname.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 请问这里有谁熟悉PHP网站编程?本菜鸟有事请教。。。江湖救急啊。。。谢谢。。。
    • UP!
    • Who developed this forum ?
      • Cannot depend on the boss....I'm a small potato.....
        • why not post your question here, there are a bunch of 闲人 here.
          • 谢谢。问题在里面。太菜了,不要笑话俺哈。。。
            how to get the information users input in the HTML FORM, like in a procedure of new user registration? I used $_POST / $_GET, but didn't work, even for the exact same sample in the online manual. Too little explaination about these functions and the interaction between HTML and PHP in that book. How do I use them? And how can I get the input information then?
            • give you an example.
              page1.html

              <form action=page2.php method=post>
              <input type=text name=user>
              <input type=submit value='Go page2'>
              </form>

              page2.php
              <?php
              echo $_POST['user'];
              ?>

              当浏览PAGE1.HTML时,输入USER, 点按'GO PAGE2'按钮, 就跳到PAGE2.PHP.
              最好找本书,系统地学习, PHP入门不难.
              • thanks.
                I exactly used this system variable, but didn't work, saying undefined index of post....then I use your code. no error, but no result or any display of my input either.....I was so stuck on it.....

                For the reference, do you have any comment? I use the online book from php.net, but not enough....
                • try
                  1. what's your platform? linux or windows?
                  2. maybe your php setting's problem, check php parameters :
                  <?php
                  echo phpinfo();
                  ?>
                  You can post here if you don't mind.
                  3. try to print $_post array.
                  <?php
                  print_r($_post);
                  ?>
                  4. search 'php $_post doesn't work' from google, take a look.
                  • Thanks. Here is the code and information.
                    The result now is no error, but displayed nothing after I inputted something in the name field and submitted.

                    //sample_register.htm
                    <html>
                    <form method="POST" action="sample_register.php" name="rname">
                    <p>Name:<input type="text" name="usrname" size="50" tabindex="1"></p>
                    <p> </p>
                    <p><input name=B1 type=submit value="Submit"></p>
                    </form>
                    <p> </p>
                    </html>

                    //sample_register.php
                    <?php
                    echo $_POST[usrname]
                    ?>

                    PHP Version => 5.0.2
                    WinXP
                    Apache 2.0.48 (win32)
                    register_globals = On (although it was recommended to be off because this often leads to security bugs.)

                    Doesn't work either if using $usrname.
                    • it is ok
                      actually please consider to turn the global option off, it is more dangerous than u ever think.
                      there might be something wrong with the mod_php module with apache. check if ur php build is ok.
                      btw, mine is using handler/action to run php script in apache.
                      • thanks a bunch...anyway...would u please give me more details? I mean how to check apache module or php build? my previous php experience is zero and just read some words from php.net....totally a greener....
                        • echo $_POST['username']; ?
                          • changed,,,,,still the same problem.
                        • php 5.0 is too old for u, yongsters like u should downgrade to a premature mate like php 4.x
                          • changed to 4.3.10 and checked every thing needed for manual installation. The old problem is still there and new one comes out...:-(((((
                            I used the code below to check if I have installed the correct php version (which is also from the guy above, bandwidth, #2018066):
                            <?php
                            print_r($_post);
                            ?>

                            <?php
                            echo phpinfo();
                            ?>

                            But often got the error of "无法显示该页". The correct information seldom came out.....(like gambling)....why this?

                            I use DzSoft PHP editor 2.0 and set the options like:
                            Use external HTTP server installed on this computer
                            host name: localhost
                            root directory: C:\Program Files\Apache Group\Apache2\htdocs

                            Must php files run in editors? Is there anything wrong with my editor configuration?
                            • 看看你的apache的logs下的error.log文件,里面一般有相对直接一点的错误信息
                              • [client 127.0.0.1] PHP Notice: Undefined variable: _post in C:\Program Files\Apache Group\Apache2\htdocs\Phpweb\myphpsetting.php on line 2
                                • 上面那个页面你是从另一个含form的页面调用过来的吗?
                                  • one is htm file, one is php file...
                                • ok
                                  looks like ur php installation does not have proper server-side api support.
                                  so http parameters are not passed into php.exe
                                  try add some lines in apache 2.0's configure file httpd.conf
                                  like the same lines in apache 1.3
                                  ScriptAlias /php/ "c:/php/php-4.3.10-Win32/"
                                  AddHandler php-script .php
                                  Action php-script "/php/php.exe"
                                  if still php can not get the input http variables, back to latest apache 1.3.x.

                                  nothing wrong with those stupid php code. sure it is the installation/setup ruins all fun of it.

                                  btw, do u know php later versions 4.3.x and 5.0/1 does not support apache 2.0 yet?
                                  • I will try your way.
                                    yeah, i know all these codes should work since they are just copied from the php manual.....I guess it must be some problem with the installation. But I checked the installation document again and again. Nothing is out of the recommendation. Sometimes I was wondering if I should check those damned configuration parameters or my brain....

                                    btw, the php installation manual says it does support apache2.x. Is there some sapi like php4apache2.dll? ( php4apache.dll is for 1.x. )
                                    • if you are under windows box, why not make it simple by using IIS to host the website? apache is not good for beginners
                                      • finally the codes will be put in a web server....it will be linux and apache with over 90% confidence level....Furthermore, I thought before that IIS was not easier than the helicopter...
                                        • At Least you can test the code. IIS is quite easy, and PHP install program will automatically config it for you.
                                          • come on. iis is not free, using apache and php u r not obligated. fight for freedom. and i don't see any reason to use iis if the program is written in PHP
                                            the code has nothing wrong.
                                            IMHO, an install program does anything automatically for an admin is just not the style we should be looking for. it would be nice to have, however, if one is not familiar with something, better spend some time on it and figure it out. this was my learning cycle b4. hehe
                  • my completed php information is here:
    • if u have some java or other OO background, 5.0 is strongly recommanded. More robust, more hierarchy way..... One problem is if your php runing on other's server, very likely it wont be supported.
    • HAHAHA!!! Finally I worked it out.....almost died.....just caught it with IIS and PHP...will try apache soon...
      basic knowledge is very important...understanding it, not only knowing it...I made very stupid mistakes of web server configuration...