Reputation: 399
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';
}
}
Upvotes: 0
Views: 1431
Reputation: 2168
It seems you are missing name="yourString"
<input type="text" name="yourString">
<input type="submit" name="submit2" value="Parse" />
Upvotes: 1
Reputation: 760
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>
Upvotes: 3