Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“之后的php代码”;如果(isset($_POST…)未运行_Php_Html_Forms - Fatal编程技术网

“之后的php代码”;如果(isset($_POST…)未运行

“之后的php代码”;如果(isset($_POST…)未运行,php,html,forms,Php,Html,Forms,正是标题所说的。我的PHP在if语句之后编写,用于检查表单的文本部分是否有任何值,但没有运行。在我代码前面编写的一个语句中,它可以正常工作,但在第二次编写时就不行了 这是我的全部代码: <?php include '../header.php'; include '../navigation.php'; ?> <div id="pageContent"> <form name="format" method="POST" action="phpFunctions

正是标题所说的。我的PHP在if语句之后编写,用于检查表单的文本部分是否有任何值,但没有运行。在我代码前面编写的一个语句中,它可以正常工作,但在第二次编写时就不行了

这是我的全部代码:

<?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'; ?>

请输入日期:
您错过了=,
name=“yourString”


输入字符串:
您错过了=,
name=“yourString”


输入字符串:

您似乎缺少name=“yourString”


您似乎缺少name=“yourString”



您正在单击
解析
按钮?您是否放置了
其他
以确认条件失败?@chris85,是的,当我单击解析按钮时什么都不做,没有。我还是PHP新手,不知道如何做that@chris85,看起来我在表单名称中缺少了一个“=”。是的,我看到了下面对deb的回答ug自己将来会使用
else
s,因此您知道代码的计算结果。在这种情况下,您应该知道
$\u POST['yourString']
没有被发送,可能已经从那里隔离了问题。@chris85 awww好的,这很有意义。谢谢你,你正在单击
解析
按钮?你是否放置了一个
其他
来确认条件失败?@chris85,是的,当我单击解析按钮时什么都不做,没有。我还是PHP新手,没有我真的不知道该怎么做that@chris85,看起来我在表单的名称中缺少了一个“=”。是的,我在下面看到了将来调试自己的答案使用
else
s,因此您知道代码的计算方式。在这种情况下,您应该知道
$\u POST['yourString']
没有被发送,可能已经从那里隔离了问题。@chris85 awww好的,这很有道理。谢谢你,dudeha,我知道它会很简单。谢谢。我应该删除它,因为它很简单吗?哈,我知道它会很简单。谢谢。我应该删除它,因为它很简单吗?
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';
    }
}
<form name="stringStuff" method="POST" action="test_index.php">
    Enter string:
    <input type="text" name="yourString">
    <input type="submit" name="submit2" value="Parse" />
</form>
<input type="text" name="yourString">
<input type="submit" name="submit2" value="Parse" />