PHP: 用readonly取代disabled来获取input值 submit a disabled input in a form could not get value

The form is like below;

<form action="sendmail.php" method="get">
    <input type="text" name="phone" id="phone" data-clear-btn="true">
    <input type="text" name="name" id="name" data-clear-btn="true">
    <input disabled="disabled" type="text" name="textinput-disabled" id="textinput-disabled" placeholder="Text input" value="<?php echo $info;?>">
</form>

$info = “type1”; and the $info works fine in the form.

but In the sendmail.php

$name=$_GET['name'];
$type=$_GET['textinput-disabled'];
$phone=$_GET['phone'];

最好的解决方法是将disabled更换成hidden或者readonly

Disabled fields are not submitted. You can make it readonly or hidden, to get value when submitted.

<input readonly type="text" name="textinput-disabled" id="textinput-disabled" placeholder="Text input" value="<?php echo $info;?>">

share: http://stackoverflow.com/a/25264539/4484798

 

更多参考:

php实现畅言留言板和网易跟帖样式

兼容IE和FF:获取Referer的JS和PHP方法 及 PHP利用curl伪造IP和来路

PHP5: mysqli 插入, 查询, 更新和删除 Insert Update Delete Using mysqli (CRUD)

 

本文: PHP: 用readonly取代disabled来获取input值 submit a disabled input in a form could not get value