dongya1875 2015-05-09 11:59
浏览 91
已采纳

访问变量一个按钮在php中输入

I have a kinda weird situation where I have to access a variable once the submit button is entered. here is the code which am working on...

echo '<form>';
echo '<input type="submit" name="report1" value="submit"></button>';
echo '<input type="text" name="inp1" id="inp1"></input>';
echo '<input type="text" name="inp2" id="inp2"></input>';
$ean = $_POST['inp1'] ;
$url = $_POST['inp2'] ;
if (isset($_POST['report'])) 
{
if ($ean=='0')
{
//do nothing 
} 
else
{
echo echo '<input type="submit" name="report2" value="submit"></button>';
}
}
if (isset($_POST['report2'])) 
{
$ean = "xyz";
echo $ean;
}
echo '</form>';

SO, here while clicking on the the Button name report2 I want to access the $ean and $url variables but its showing null means the variables are not storing the value input in the inp1 and inp2 input box...can any one please suggest me what to do.

  • 写回答

1条回答 默认 最新

  • dongqie4402 2015-05-09 20:18
    关注

    By the help of the comments posted here I did the following trick and it works for me...

    echo '<input type="hidden" name="hidTitle" value="'.$ean.'" />';
    

    and access this variable by _POST['hidTitle']

    and it works for me

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答