表单 php 提交 传递 数据
在一个php中,我定义了两个表单,当第一个表单提交后,生成了第二个表单,提交第二个表单后,就取不到第一个表单的数据了,该怎么办?//第一个表单
echo "";//第二个表单
var_dump($m);
?>
提交第二次后就得不到$m了,该怎么做才能将$m传递到最后呢?
本人新手,不懂得cookie、session。谢谢了!
回复讨论(解决方案)
这个最合理的做法就是用session或cookie保存前一次的提交,不懂的话就干脆以此为契机,学吧
这个最合理的做法就是用session或cookie保存前一次的提交,不懂的话就干脆以此为契机,学吧
恩,我临时学了一下,我的做法是两个表单分别放在两个php文件中,然后在第二个php中写了setcookie("m1",$m,time()+3600);
$m2=$_COOKIE["m1"];
然后我就用m2这个变量当做m的值,但是当我准备生成第三个表单的时候,怎么取到m?我觉得php跳转到下一个网页后就得不到前一个php的值了。如果用xml可以解决这种问题吗?
不要把事情弄得那么复杂
你的第二的个表单是第一个表单的处理程序创建的
那么就把第一个表单的提交以隐藏变量的形式放到第二个表单里就是了
不要把事情弄得那么复杂
你的第二的个表单是第一个表单的处理程序创建的
那么就把第一个表单的提交以隐藏变量的形式放到第二个表单里就是了
我也有这么想,但是不会隐藏变量啊,希望有代码参考一下,谢谢!
不要把事情弄得那么复杂
你的第二的个表单是第一个表单的处理程序创建的
那么就把第一个表单的提交以隐藏变量的形式放到第二个表单里就是了
他这种需求我很久以前遇到过,就是做问卷调查时一道题一页??回答后才出现下一个问题,最初也是逐个做hidden传下去的,后来发觉十几道题就嫌麻烦了,用session反而简单多了
cookie我也觉得麻烦,如果用cookie就干脆做“假提交”,一次把题都发过去,用js把后面的题隐藏,逐个显示,到最后一题才一并提交
session的缺点是有时效性,需要在一定时间有动作才不会丢失值
cookie的缺点是客户端可以造假
在
间加入 php 代码foreach($_POST as $k=>$v) echo "";
怎么会麻烦呢?使用了 session 的表单页,无论怎么设置,“回退”的表现都不尽人意
不要把事情弄得那么复杂
你的第二的个表单是第一个表单的处理程序创建的
那么就把第一个表单的提交以隐藏变量的形式放到第二个表单里就是了
我也有这么想,但是不会隐藏变量啊,希望有代码参考一下,谢谢!
不要把事情弄得那么复杂
你的第二的个表单是第一个表单的处理程序创建的
那么就把第一个表单的提交以隐藏变量的形式放到第二个表单里就是了
他这种需求我很久以前遇到过,就是做问卷调查时一道题一页??回答后才出现下一个问题,最初也是逐个做hidden传下去的,后来发觉十几道题就嫌麻烦了,用session反而简单多了
cookie我也觉得麻烦,如果用cookie就干脆做“假提交”,一次把题都发过去,用js把后面的题隐藏,逐个显示,到最后一题才一并提交
session的缺点是有时效性,需要在一定时间有动作才不会丢失值
cookie的缺点是客户端可以造假
不是吧,我生成的表单是根据上一个表单提交数据才能用的,没有输出上限,hidden不行。
一样的,js也能根据“提交”内容生成控件,只是你不熟悉而已
实在搞不定就按#6老徐的方法写,这个思路最简单
我个人对数组相对熟悉些,所以习惯用session记录,懒得每次都对前面提交的数据再遍历一次
你可以这么的。两方式
一种方式就是分两页面:第一步提交后,到第二步的时候读取出来。
两步在一个页面:先用js隐藏第二步,ajax提交,那么再第二步也能获取第一步的值。
不要把事情弄得那么复杂
你的第二的个表单是第一个表单的处理程序创建的
那么就把第一个表单的提交以隐藏变量的形式放到第二个表单里就是了
恩,我觉得这个方法最方便,但是没有出结果,你看看我的代码好吗?
这是第二个php:
foreach($_POST as $k=>$v)
{
echo "";
}
var_dump($m);
echo "
?>
这是第三个php:
foreach($_POST as $k=>$v)
{
echo "";
}
$n;
for($i=1;$i {
$h="n".$i;
$n[]=$_POST["$h"];
}
var_dump($n);
?>
跳转到第三个php输出的是null,网址上也仅仅跟着n1、n2、n3...的值,没有出现m,怎么回事呢?
一样的,js也能根据“提交”内容生成控件,只是你不熟悉而已
实在搞不定就按#6老徐的方法写,这个思路最简单
我个人对数组相对熟悉些,所以习惯用session记录,懒得每次都对前面提交的数据再遍历一次
谢谢你!但是我用6#上面的代码还是出不来结果,怎么回事?
放在

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software