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 多址通信方式的抗噪声性能和系统容量对比
  • ¥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 软件测试决策法疑问求解答