dth54864 2016-07-08 06:16 采纳率: 0%
浏览 22

PHP没有发布(是的,定义了名称标签)

After reading 20+ posts (a large majority of which involve people failing to put the name attribute in their input tags), I have a stupidly simple script:

<form action="submit_form.php" method="post">
        Name: <input type="text" name="name"><br>
        <input type="submit">
</form>

and on submit_form.php I have

<?php echo $_POST["name"]; ?>

Which spits out the text below.

Notice: Undefined index: name in C:\Users...\PhpstormProjects...\submit_form.php on line 1

I've been using PHP for years though this is the first PHP project on this fresh machine so this is the first post type action I've tried on the new configuration. With that said, I have a feeling it has to do with my PHP configuration? What should I look for inphpinfo()?

As a probably very important note:

  • I'm running this on PhpStorm
  • I've set all the deployment settings (I use PhpStorm at work with no problem)
  • After posting the form from the index page, I've had submit_form.php only execute phpinfo(); and that works except...
  • I get random 502's... Half of the time I see the PHP info, the other half of the time I get 502 Bad Gateway...

I've also tried:

if(isset($_POST["name"])) {
 echo $_POST["name"];
}
  • 写回答

2条回答 默认 最新

  • dongwei1921 2016-07-08 06:39
    关注

    First try

    var_dump($_POST)
    

    Because i think you're posting data to a wrong file. that's why you're not getting anything from var_dump .. please check that submit_form.php filename

    if it doesn't work!

    How about try something from beginning .

    First create a file name: setup.php

    <form action="post.php" method="post">
            Name: <input type="text" name="name"><br>
            <input type="submit" name="submit">
    </form>
    

    Then Create another file in the same directory called post.php

    <?php 
    
         if(isset($_POST["name"])) {
           $name = $_POST["name"];
         }   
    
         echo $name;
    

    ?>

    Hopefully my solution will work for you!

    评论

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目