检查提交值是否在数组中?(Check wheter submitting value is in array?)
我最近读过一篇文章说,你永远不应该信任发送数据中的用户。
所以我们假设我有以下表单输入:
<label for="input1">Answer 1</label> <input type="radio" name="question1" value="answer1" id="input1" /> <label for="input2">Answer 2</label> <input type="radio" name="question1" value="answer2" id="input2" /> <label for="input3">Answer 3</label> <input type="radio" name="question1" value="answer3" id="input3" />
是否可以检查发布的答案是否在回答里面:
$question1_answers = array("answer1", "answer2", "answer3"); $answer1 = $_POST['question1']; if ( in_array($answer1, $question1_answers) ) { echo "OK!"; } else { echo "Please select proper answer!"; }
或者,也许上面的代码是不必要的,我应该简单地阅读
$_POST['question1']
,这将足够?I have recently read an article that said, that you should never trust user in the sending data.
So let's say that I have following form inputs:
<label for="input1">Answer 1</label> <input type="radio" name="question1" value="answer1" id="input1" /> <label for="input2">Answer 2</label> <input type="radio" name="question1" value="answer2" id="input2" /> <label for="input3">Answer 3</label> <input type="radio" name="question1" value="answer3" id="input3" />
Is it okay to check whether posted answer is inside aray with answers:
$question1_answers = array("answer1", "answer2", "answer3"); $answer1 = $_POST['question1']; if ( in_array($answer1, $question1_answers) ) { echo "OK!"; } else { echo "Please select proper answer!"; }
Or maybe above code is unnecessary and I should simply read
$_POST['question1']
and it will be enough?
原文:https://stackoverflow.com/questions/12814021
最满意答案
要获得Vbox-log,您需要:
1)添加AutoConfig.kmk
VBOX_WITH_R0_LOGGING := 1
2)编译
kmk BUILD_TYPE=debug
3)然后,
你应该设置环境变量VBOX_LOG (what kind of module you want to see in your log) VBOX_LOG_FLAGS VBOX_LOG_DEST (location of log)
更多信息: https : //www.virtualbox.org/wiki/VBoxLogging
之后你应该从这个终端窗口运行VirtualBox。3 - 例如
export VBOX_LOG_DEST="dir=/home/guest/tmp" export VBOX_LOG=hgcm.e.l.f export VBOX_LOG_FLAGS="buffered thread msprog" (optionaly)
To get Vbox-log you need:
1) To add in AutoConfig.kmk
VBOX_WITH_R0_LOGGING := 1
2) Compile with
kmk BUILD_TYPE=debug
3) Then,
you should set environment variableVBOX_LOG (what kind of module you want to see in your log) VBOX_LOG_FLAGS VBOX_LOG_DEST (location of log)
more info there : https://www.virtualbox.org/wiki/VBoxLogging
And after it you should run VirtualBox from this terminal window.3 - For example
export VBOX_LOG_DEST="dir=/home/guest/tmp" export VBOX_LOG=hgcm.e.l.f export VBOX_LOG_FLAGS="buffered thread msprog" (optionaly)
相关问答
更多-
因此,VirtualBox IRC频道irc://chat.freenode.net/#vbox上的某个人告诉我,客人新增功能在Chrome操作系统上无法使用。 在尝试了@sarnold的建议后,运行了mount -oremount,rw / ,我被告知 Unable to determine your Linux distribution So someone on the VirtualBox IRC channel irc://chat.freenode.net/#vbox told me that ...
-
要获得Vbox-log,您需要: 1)添加AutoConfig.kmk VBOX_WITH_R0_LOGGING := 1 2)编译 kmk BUILD_TYPE=debug 3)然后, 你应该设置环境变量 VBOX_LOG (what kind of module you want to see in your log) VBOX_LOG_FLAGS VBOX_LOG_DEST (location of log) 更多信息: https : //www.virtualbox ...
-
在Windows 10主机网络上访问VirtualBox Mac OS来宾(Access VirtualBox Mac OS guest on Windows 10 host network)[2022-11-14]
我有它....因为我在虚拟机上,我必须将我的网络适配器设置设置为桥接适配器而不是NAT。 在设置为桥接适配器后,我的guest mac os的IP也发生了变化,现在它看起来像192.168.8.103,这与我之前获得的不同,这个IP可以从Windows主机访问,我可以远程登录。 这可能会帮助其他人遇到类似的麻烦并节省一些时间。 I have got it....as I'm on virtualbox, I have to set my network adapter setting to bridge a ... -
您在构成您的nixos配置或模块的fileSystems两次定义fileSystems 。 在第一个定义中它是一个列表,而在第二个定义中,通过使用嵌套属性集合速记符号将fileSystems定义为attrset。 实际上,这个错误是由Nix语言而不是NixOS模块系统产生的。 通过使用与/virtualboxshare相同的符号定义所有文件系统,可以解决此错误。 为了更好地理解嵌套的attrsets,使用nix repl可能会很有用: $ nix repl Welcome to Nix version 2. ...
-
在VirtualBox中通过主机和来宾之间的COM端口连接(Connection through COM port between host and guest in VirtualBox)[2022-03-05]
首先,VirtualBox不会为您的主机创建串行端口。 因此,您必须使用其他软件在主机上创建两个虚拟COM端口,并虚拟地桥接这两个端口。 然后使用一个端口连接到Simulink,其他必须以VM COM端口使用此端口的方式进行设置。 为了在Windows上创建虚拟COM端口,我将使用伪造RS232串行端口的 com0com 。 您可以使用任何您喜欢的软件。 安装com0com后,从C:\Program Files (x86)\com0com 。 现在点击申请。 现在你将COM10和COM10桥接(就像COM9 ... -
这个问题似乎不是一个错误,而是我的误解。 This issue seems to not be a bug but my misunderstanding.
-
您的外部IP是否静态与访问LAN上的虚拟化服务器无关。 将VirtualBox设置为桥接模式。 只需确定计算机的DHCP选择的内部IP(通常为192.168.1.SOMETHING ),并将最后一个数字替换为小于250的另一个数字。例如,如果您的计算机是192.168.1.6可以在VM上正常工作(选择一个高数字来消除冲突)。 使用控制面板 - >适配器设置进行设置。 重新启动VM。 以192.168.1.70(或您之前选择的地址)连接到MySQL。 注意:如果您的计算机的地址位于不同的子网(192.168. ...
-
我的猜测是,虽然您的代码只占用一个核心,但执行时您的程序可以在操作系统执行期间切换到不同核心的上下文中。 这就是为什么你看到所有核心使用,但尖峰发生在不同的时间。 (但这样做比测量资源监视器更准确)。 My guess is that while your code only takes one core, your program when executed can be switched into and out of context on different cores during the exec ...
-
访问[开始菜单]并在[搜索程序和文件]中键入运行 。 在[运行行]里面输入gpedit.msc 。 在那里,转到Windows设置 - >安全设置 - >本地策略 - >安全选项 - > [ 帐户:限制本地帐户使用空白密码仅控制台登录 ]并将其设置为已禁用 。 VM重启后,应该解决了。 Access [Start menu] and in [search program and files] type Run. Inside [Run line] type gpedit.msc. There, go to ...
-
访问VirtualBox Guest Shared Folder上的Web文件(Access Web Files on VirtualBox Guest Shared Folder)[2022-06-07]
要更改目录的权限,可以在mount语句中使用dmode和fmode参数: mount -t vboxsf -o rw,dmode=775,fmode=775 shared shared 您不需要指定uid和gid,但需要将apache用户添加到vboxsf组: usermod -G vboxsf apache 最后,实际使它工作的是你需要禁用selinux。 现在,我可以在Windows中查看/编辑我的文件,让VM在浏览器中为它们提供服务。 这样做的目的是能够在Windows上开发,但让我的Web应用程 ...