您的位置 首页 php

php获取表单数据的方法

php获取表单数据的方法

获取表单数据是表单应用中最基本的操作,表单数据的传递方法有两种,即POST()方法和GET()方法,下面说说PHP中这两种方法的优缺点和案例!

一、使用POST()方法提交表单

应用POST()方法时,只需将<form>表单中的属性method设置成POST即可,POST()方法不依赖URL,不会显示在地址栏。POST()方法可以没有限制地传递数据到服务器, 所有提交的信息在后台传输,用户在浏览器端看不到这一过程的,安全性高。所以POST()方法比较适合用于发送一个保密的(如信用卡号)或者容量较大的数据到服务器。

实例:使用POST()方法发送文本框信息到服务器!

php获取表单数据的方法

在上面的代码中,form表单的method属性指定了POST()方法的传递方式,并通过action属性指定了数据处理页为txt.php。因此,当点击“提交”按钮后,即提交文本框的信息到服务器,运行结果如下

php获取表单数据的方法

二、使用GET()方法提交表单

GET()方法是<form>表单中method属性的默认方法,使用GET()方法提交的表单数据被附加到URL后, 并作为URL的一部分发送到服务器端。在程序的开发过程中,由于GET()方法提交的表单数据是附加到URL上发送的,因此,在URL的地址栏中将会显示“URL+用户传递的参数”。

GET()方法的传参格式如下:

php获取表单数据的方法

其中,url为表单响应地址(如 ),name1为表单元素的名称,value1为表单元素的值,url和表单元素之间用“?”隔开,而多个表单元素之间用“&”隔开,每个表单元素的格式都是name=value,固定不变。

实例:创建一个表单来实现应用GET()方法提交用户名和密码,并显示在URL地址栏中,添加一个文本框,命名为user 添加一个密码域,命名为pwd;将表单的method属性设置为GET()方法!如下:

php获取表单数据的方法

运行本实例,在文本框中输入用户名和密码,单击“提交”按钮,文本框内的信息就会显示在URL地址栏中,如下:

php获取表单数据的方法

可以看出,这种方法会将参数暴露。如果用户传递的参数是非保密性的参数,那么采用GET()方法传递数据是可行的,如果用户传递的是保密性的参数(如密码),这种方法就会不安全。

文章来源:智云一二三科技

文章标题:php获取表单数据的方法

文章地址:https://www.zhihuclub.com/80117.shtml

关于作者: 智云科技

热门文章

评论已关闭

41条评论

  1. Complications of Treatment We truly approach each patient as an individual as a unique person with a unique cancer situation

  2. Previously it has been demonstrated that substitution of NMe Ser 4 into leuprolide d Leu 6 desGly NH 2 10, Pro ethylamide 9 GnRH can stabilize the molecule against enzymatic degradation Garnick and Glode, 1984, as can modifications of positions 1, 2, or 3 Haviv et al Chris XFEoZAiJHaN 5 21 2022

  3. 130 A Col2a1 Cre driver mouse line provides some clues about the utility of the inducible Cre driver line

  4. Risks of cancer recurrence, of cancer in the other breast, and of death from breast cancer were all lower in women who took tamoxifen for 5 years than in those who took it for 2 years

  5. I m completely overloaded and I ve decided that I need some information tailored to my personal situation

  6. Possible interactions with carnitine l carnitine My dr said at my age 41, the chance of multiples is really low, but I still worry that too many follicles could develop

  7. The Working Group noted that other factors may also have been present in the blood of the human volunteers

  8. Pharmacokinetic parameters appear to be similar following administration of naproxen suspension or tablets in pediatric patients

  9. At present, only can you smoke while on blood pressure medication sensitive to hypertension medications some second rate legions are stationed in the important places on the border of the Principality, and the customs defense is useless, As soon as the can you smoke while on blood pressure medication machete and the Dragon Slaying Spear touched, they banged and turned into pieces of iron in the sky Consistent to the reports that overexpression of GLUT1 enables to transport DHA more efficiently into cells 26, 36, we did find that ER6 cells have higher intracellular DHA concentration after DHA treatment than HCC827 cells

  10. 2015, 141 5, 769 784 The data were recorded and stimuli presented using NeuroScan equipment with Synamp amplifiers and STIM Audio System and software NeuroScan Labs, Sterling, VA, and sounds were applied to the participant binaurally by EAR insert earphones Aearo Company Auditory System, Indianapolis, IN

  11. trihexyphenidyl zovirax generico pomada preo Behind the scenes, the Mets are pushing for Harvey to get that starting nod for the National League

  12. It can also be taken by dogs on a long term basis to help prevent heartworm disease Received August 31, 2016; Accepted December 12, 2016; Published January 4, 2017

  13. Any prior use of testosterone treatments injectable, pelleted, transdermal or sublingual within the last 6 months Use of spironolactone, cimetidine, Clomid, 5О±- reductase inhibitors, hCG, androgen, estrogen, anabolic steroid, DHEA, or herbal hormone products during the study Use of Clomid in the past year Any clinically significant laboratory abnormality that does not have prior written sponsor approval Grob, JJ, Mege, JL, Capo, C, Jancovicci, E, Fournerie, JR, Bongrand, P

  14. In this study, when included in a multivariate model including subtypes of BC, age, histological subtypes, tumour size, number of affected lymph nodes, grade and nuclear proliferation index, age at diagnosis was the second most important factor for the development of BM П‡ 2 17 after BC subtype П‡ 2 28 39

  15. Where indicated, culture supernatants were collected and assayed using an IL 12 p70 ELISA kit Mabtech AB, Nacka Strand, Sweden

  16. Even though the large individual variation in Lp a levels may mask such effects in population studies, two studies reported 8 to 13 population based increases after menopause Castonguay, The induction of cyclooxygenase 1 by a tobacco carcinogen inU937 human macrophages is correlated to the activation of NF Оє B, Carcinogenesis, vol

  17. What’s up, after reading this awesome post i am also delighted
    to share my familiarity here with friends.

  18. These are really fantastic ideas in on the topic of blogging.

    You have touched some nice factors here. Any way keep up wrinting.

  19. Excellent site you have got here.. It’s hard to find quality writing like
    yours these days. I really appreciate individuals like you!
    Take care!!

  20. Hi! I just wanted to ask if you ever have any problems with hackers?

    My last blog (wordpress) was hacked and I ended up losing many months of hard
    work due to no backup. Do you have any methods to prevent
    hackers?

  21. Howdy very nice website!! Man .. Excellent .. Superb ..
    I’ll bookmark your website and take the feeds additionally?
    I am satisfied to find a lot of useful info here within the put up, we need work out extra
    techniques on this regard, thank you for sharing. . .
    . . .

  22. My spouse and I stumbled over here from a different
    web address and thought I might check things out. I like what I see
    so i am just following you. Look forward to checking out your web page yet again.

  23. I simply couldn’t depart your web site before suggesting that I actually
    enjoyed the standard information an individual supply on your visitors?
    Is gonna be back incessantly to inspect new posts

  24. It is perfect time to make a few plans for the long run and it is time to be happy.
    I’ve learn this post and if I may I wish to recommend you some
    fascinating issues or advice. Perhaps you can write next
    articles referring to this article. I desire to learn more issues approximately it!

  25. It’s really a cool and useful piece of info. I’m glad that you
    simply shared this helpful info with us. Please keep us up to date like this.
    Thanks for sharing.

  26. I was wondering if you ever considered changing the layout of your website?

    Its very well written; I love what youve got to say. But maybe you
    could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having 1
    or two pictures. Maybe you could space it out better?

  27. It’s in fact very complicated in this active life to
    listen news on TV, so I simply use world wide web for that purpose,
    and get the newest news.

  28. This post is in fact a nice one it helps new internet visitors,
    who are wishing in favor of blogging.

  29. It’s perfect time to make some plans for the future and it is time
    to be happy. I have read this post and if I could I want to suggest you few interesting things or tips.
    Maybe you can write next articles referring to this article.
    I desire to read even more things about it!

网站地图