douwen3973 2016-11-21 03:25
浏览 115
已采纳

在“if(isset($ _ POST ...”)未运行之后的php代码

Exactly what the title says. My PHP written after an the an if statement to check if a text portion of a form has any value is not running. It works fine in one written earlier in my code, but not the second time.

Here is my whole code:

<?php include '../header.php'; include '../navigation.php'; ?>

<div id="pageContent">

<form name="format" method="POST" action="phpFunctions.php">
    Please input date: 
    <input type="date" name="date" value="<?php echo date('Y-m-d'); ?>" />
    <input type="submit" name"submit1" value="Format" />
</form>

<?php

if (isset($_POST['date'])) {
    $new_date = $_POST['date'];
    $date = new DateTime($new_date);
    echo 'M-D-Y Format: ' . $date->format('m-d-Y') . '<br>';
    echo 'D-M-Y Format: ' . $date->format('d-m-Y');
}

?>

<form name="stringStuff" method="POST" action="phpFunctions.php">
    Enter string:
    <input type="text" name"yourString">
    <input type="submit" name"submit2" value="Parse" />
</form>

<?php

if (isset($_POST['yourString']) && !empty($_POST['yourString'])) {
    echo 'ayyyyyy lmao';
    $new_string = $_POST['theString'];
    $trimmed_string = trim($new_string);
    echo 'ayyyyyy lmao';
    echo 'String Length: ' . strlen($new_string) . '<br>';
    echo 'Trim Whitespace: ' . $trimmed_string . '<br>';
    echo 'Lowercased: ' . strtolower($new_string) . '<br>';
    if(strpos($new_string, 'DMACC') !== false) {
        echo 'String contains DMACC';
    }
    else {
        echo 'String does not contain DMACC';
    }
}

?>

</div>

<?php include '../footer.php'; ?>

The portion of the code that isn't working is this portion after what I mentioned

if (isset($_POST['yourString']) && !empty($_POST['yourString'])) {
    echo 'ayyyyyy lmao';
    $new_string = $_POST['theString'];
    $trimmed_string = trim($new_string);
    echo 'ayyyyyy lmao';
    echo 'String Length: ' . strlen($new_string) . '<br>';
    echo 'Trim Whitespace: ' . $trimmed_string . '<br>';
    echo 'Lowercased: ' . strtolower($new_string) . '<br>';
    if(strpos($new_string, 'DMACC') !== false) {
        echo 'String contains DMACC';
    } else {
        echo 'String does not contain DMACC';
    }
}
  • 写回答

2条回答 默认 最新

  • douyan1903 2016-11-21 03:33
    关注

    you missed = , name="yourString"

    <form name="stringStuff" method="POST" action="test_index.php">
        Enter string:
        <input type="text" name="yourString">
        <input type="submit" name="submit2" value="Parse" />
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂