I am trying to make it where submit button is pressed and ALL inputs are only left with letters and numbers and then echoed out onto a page. I'm not getting any errors but it still won't print out formatted text. I can echo out a 3 lined command but when converting it to an input I get lost.
Can anyone help me get the code to act the way I want it? I'm not trying to sanitize data or insert into a database. I'm simply trying to remove unreadable words onto a page due to fat fingers, drunks or whatever
I've tried
preg_replace('/^[a-zA-Z0-9]+/', $name)
preg_replace('/^[a-zA-Z0-9]+/', $_POST["name"])
<html>
<head>
<title>test</title>
</head>
<body>
<form id="form" class="appnitro" method="post" action="">
<h2>stripping extra crap</h2>
<div>
<br>
name<br>
<input id="element_1" name="name" type="text" maxlength="20" value="test$%+=-?"/> <br>
test1<br>
<input id="element_1" name="test1" type="text" maxlength="20" value="test$%+=-?"/> <br>
test2<br>
<input id="element_1" name="test2" type="text" maxlength="20" value="test$%+=-?"/> <br>
test3<br>
<input id="element_1" name="test3" type="text" maxlength="20" value="test$%+=-?"/> <br>
</div>
<input id="" class="button_text" type="submit" name="" value="Submit" />
</form>
</div>
</body>
</html>
<?php
if (empty($name) && empty($test1) && empty($test2) && empty($test3)) {
echo 'Please fill in the fields';
return false;
}
if (isset($_POST['submit'])){
implode("", $_POST);
preg_replace('/^[a-zA-Z0-9]+/', $_POST);//testing string to replace $name to letters and numbers only
}
echo 'name with only letters and numbers?<br>';
echo $name;
echo '<br>';
echo '<br>';
echo 'is post array still an array or string after implode?<br>';
echo $_POST;
echo '<br>';
echo '<br>';
echo 'test1 with only letters and numbers?<br>';
echo $test1;
echo '<br>';
?>
--------------------------------
<?php
foreach($_POST as $key=>$value)
{
echo "<br>$key=$value<br>";
}
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
?>