I have a list of urls that I want to extract the email or from the href or from the text. Each page has one email only.
The problem is that my list is big and can not do it manually.
EMAIL
How can I do this using PHP, regex?
/mailto:([a-zA-Z0-9_\.-]+#[\da-z\.-]+\.[a-z\.]{2,6})"/gm
see this demo https://regex101.com/r/mC7jM3/1
Extract email from url contain
<?php
$the_url = isset($_REQUEST['url']) ? htmlspecialchars($_REQUEST['url']) : '';
if (isset($_REQUEST['url']) && !empty($_REQUEST['url'])) {
$text = file_get_contents($_REQUEST['url']);
}
elseif (isset($_REQUEST['text']) && !empty($_REQUEST['text'])) {
$text = $_REQUEST['text'];
}
if (!empty($text)) {
$res = preg_match_all(
"/[a-z0-9]+([_\\.-][a-z0-9]+)*#([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", $text, $matches
);
if ($res) {
foreach (array_unique($matches[0]) as $email) {
echo $email . "<br />";
}
}
else {
echo "No emails found.";
}
}
?>
<form method="post" action="">
Please enter full URL of the page to parse (including http://):<br />
<input type="text" name="url" size="65" value="<?php echo $the_url; ?>"/><br />
<input type="submit" name="submit" value="Submit" />
</form>
Related
<?php
$data = file_get_contents("http://localhost/traveller/index.html");
$regex = '$_POST[/"search"/]';
if (isset($_POST["sub"])){
if (preg_match($regex, $data)) {
echo $regex;
} else {
echo "not found";
}
}
?>
<form action="searching.php" method="POST">
Search: <br>
<input type="text" name="search">
<input type="submit" name="sub">
</form>
on running this program i get:
Warning preg_match(): No ending delimeter '$' found on line 6. not
found
what should i do now?
I guess you want:
$data = file_get_contents("http://localhost/traveller/index.html");
$regex = $_POST["search"];
if (isset($_POST["sub"])) {
if (preg_match('/' . preg_quote($regex) . '/i', $data)) {
echo $regex;
} else {
echo "not found";
}
}
I guess this is what you are looking for:
Your don't need the regular expression at all.
Here is the code for what you need.
Try this.
<?php
$data = file_get_contents("http://localhost/traveller/index.html");
if (isset($_POST["search"])&&!empty($_POST["search"])) {
$search_str = $_POST["search"];
if (strpos($data,$search_str)!== false) {
echo $search_str;
}
else {
echo "not found";
}
}
?>
<form action="searching.php" method="POST">
Search: <br>
<input type="text" name="search">
<input type="submit" name="sub">
</form>
I have a form than when I submit incorrectly no error is displayed
<form action="emailSubs.php" method="post">
<p>Would you like to subscribe to our newsletter ?</p>
<p>Name: <input type="text" name="name"><br /></p>
<p>E-mail: <input type="text" name="Email"><br /></p>
<p><input type="submit" name="submit"><br /></p>
</form>
<?php
function validateEmail($data, $fieldName) {
global $errorCount;
if(empty($data)) {
echo "\"$fieldName\" is a required
field.<br />\n";
++$errorCount;
$retval = "";
} else { // olny clean up the input if it isn't
// empty
$retval = trim($data);
$retval = stripslashes($retval);
$pattern = "/^[\w-]+(\.[\w-]+)*#" .
"[\w-]+(\.[\w-]+)*" .
"(\[[a-z]]{2,})$/i";
if(preg_match($pattern, $retval) ==0) {
echo "\"$fieldName\" is not a valid E-mail
address.<br />\n";
++$errorCount;
}
}
return ($retval);
}
?>
I think it may be the pattern but am not sure what the problem may be
The problem is that you do not have the two things connected properly...
Leave your form in a separate file from emailSubs.php -
While this is not a necessary step, it will hopefully help you understand the way this works (not to mention it is a much neater / organized way to do it)
<form action="emailSubs.php" method="post">
<p>Would you like to subscribe to our newsletter ?</p>
<p>Name: <input type="text" name="name"><br /></p>
<p>E-mail: <input type="text" name="Email"><br /></p>
<p><input type="submit" name="submit"><br /></p>
</form>
Now, in your emailSubs.php file :
<?php
function validateEmail($data, $fieldName) {
global $errorCount;
if(empty($data)) {
echo "\"$fieldName\" is a required
field.<br />\n";
++$errorCount;
$retval = "";
} else { // olny clean up the input if it isn't
// empty
$retval = trim($data);
$retval = stripslashes($retval);
$pattern = "/^[\w-]+(\.[\w-]+)*#" .
"[\w-]+(\.[\w-]+)*" .
"(\[[a-z]]{2,})$/i";
if(preg_match($pattern, $retval) ==0) {
echo "\"$fieldName\" is not a valid E-mail
address.<br />\n";
++$errorCount;
}
}
return ($retval);
}
?>
But, you aren't done, yet -!
You see, you have to connect the two ---
In your form, you specified method="post" - so, we do this:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
?>
Now, there are plenty of good reasons to not use regexp to validate your form.
This is a good read on that topic.
So, what you might do instead, could look like this:
<?php
if(ctype_alnum($_POST['name']) == true){
$name = $_POST['name'];
} else {
exit("Please enter a valid name");
}
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL){
$email = $_POST['email'];
} else {
exit("Please enter a valid email address");
}
?>
And you see? That makes for a much cleaner way to handle your validation.
SO, Full circle, your code didn't display an error because there was nothing to display that error.
I noticed that you have a form, and a function but you don't call the function when the form is submitted. Maybe this is something you are doing outside the scope of the code you included, but just in case, I modified it to be a complete interaction between submission/function call and the form itself. Also, why not use filter_var instead of a regular expression?
Code (working on my local server):
<?php
function validateEmail($data, $fieldName)
{
global $errorCount;
$errorCount=0;
if(empty($data))
{
echo "\"$fieldName\" is a required
field.<br />\n";
++$errorCount;
$retval = "";
}
else
{
// olny clean up the input if it isn't
// empty
$retval = trim($data);
$retval = stripslashes($retval);
if(!filter_var($_POST['Email'], FILTER_VALIDATE_EMAIL))
{
echo "\"".$_POST['Email']."\" is not a valid E-mail
address.<br />\n";
++$errorCount;
}
}
return ($retval);
}
if(isset($_POST['submit']))
{
$email=validateEmail($_POST['Email'], "Email");
if(empty($errorCount))
{
//create subscription
echo "Subscribed!";
}
}
?>
<form action="test.php" method="post">
<p>Would you like to subscribe to our newsletter ?</p>
<p>Name: <input type="text" name="name" value="<?php echo $_POST['name'];?>"><br /></p>
<p>E-mail: <input type="text" name="Email" value="<?php echo $_POST['Email'];?>"><br /></p>
<p><input type="submit" name="submit"><br /></p>
</form>
I'm writing a function that takes the content from $_POST, inserts it in a string and then returns the resulting string
To the question "What is your favorite color?" the user inputs blue
To the question "What is your favorite animal?" the user inputs dog
$content = "The visitor's favorite color is {color}";
$content = sentenceBuilder($content);
$content = "The visitor's favorite animal is a {animal}";
$content = sentenceBuilder($content);
function sentenceBuilder($content){
global $_POST;
foreach($_POST as $key => $value){
if($key=='color'){
$content = preg_replace("/\{($key+)\}/", $value, $content);
}
if($key=='animal'){
$content = preg_replace("/\{($key+)\}/", $value, $content);
}
}
return $content;
}
This returns "The visitor's favorite color is blue" and "The visitor's favorite animal is a dog." If they leave the color element blank, it returns "The visitor's favorite color is " and "The visitor's favorite animal is a dog". If they leave both elements blank, it returns 2 incomplete sentences.
So, I tried to modified it to say so that if $value was empty, the function would just skip it and move on to the next (as this uses every form element that moved over in the $_POST)...
if($key=='color' && $value!=''){
$content = preg_replace("/\{($key+)\}/", $value, $content);
}else{
$content ='';
}
if($key=='animal' && $value!=''){
$content = preg_replace("/\{($key+)\}/", $value, $content);
}else{
$content ='';
}
With this added, the result I get is blank. No sentences or anything. Even if they fill out the elements, the result is still blank with this code added.
So I tried this instead.
function sentenceBuilder($content){
global $_POST;
foreach($_POST as $key => $value){
if(isset($value) && $value!=''){
if($key=='color'){
$content = preg_replace("/\{($key+)\}/", $value, $content);
}
if($key=='animal'){
$content = preg_replace("/\{($key+)\}/", $value, $content);
}
else{
$content = '';
}
}
return $content;
}
This yielded the same results.
TLDR;
I want to be able to have this function replace content with values that are not empty with a sentence. The ones that are empty, I would like for the content to be not displayed.
UPDATE
I got the code to work. Had to redesign it to make it happen though.
<?php
if(isset($_POST)){
$content = "The visitor's favorite color is {color}";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor's favorite animal is a {animal} from {land}";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor is from {land}";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor is from Iowa";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor is from {state}";
echo sentenceBuilder($content);
}
function sentenceBuilder($content){
preg_match("/\{(.*?)\}/", $content, $checkbrackets);
if(!empty($checkbrackets)){
$gettext = str_replace('{', '', $checkbrackets[0]);
$gettext = str_replace('}', '', $gettext);
if(array_key_exists($gettext,$_POST)){
if(!empty($_POST[$gettext])){
$content = preg_replace("/\{($gettext+)\}/", $_POST[$gettext], $content);
}else{
$content = '';
}
}
}
return $content;
}
?>
<form method="post" action"sentencebuilder.php">
<input type="text" name="color" />
<input type="text" name="animal" />
<input type="text" name="land" />
<input type="submit" />
</form>
Thanks for the help Guys. Enter it in and you'll see what I was going for. I am currently working on it to change additional brackets that exist within the question.
Use this code, definitely that's the solution of you problem:-
<?php
$main_content = array();
if(isset($_POST['submit'])) {
unset($_POST['submit']);
$main_content['color'] = "The visitor's favorite color is {color}";
$main_content['dog'] = "The visitor's favorite dog is {dog}";
$main_content['school'] = "The visitor's favorite school is {school}";
$formData = array_filter($_POST);
if(!empty($formData)) {
echo sentenceBuilder($formData, $main_content);
}
}
function sentenceBuilder($formData=null, $main_content=null){
$newContent = "";
foreach ($formData as $key => $value) {
$newVal = "";
$newVal = preg_replace("/\{($key+)\}/", $value, $main_content[$key]);
$newContent .= $newVal.". <br/>";
}
return $newContent;
}
?>
<form method="post" action="#">
<input type="text" name="color" placeholder="color" />
<input type="text" name="dog" placeholder="dog" />
<input type="text" name="school" placeholder="school" />
<input type="submit" name="submit" />
**OUTPUT:**
The visitor's favorite color is RED.
The visitor's favorite dog is BULLDOG.
The visitor's favorite school is CAMPUS SCHOOL.
Hope this will help you
<?php
$content = '';
echo $content = sentenceBuilder($content);
function sentenceBuilder($content){
global $_POST;
$content = "The visitor's favorite color is {key}";
foreach($_POST as $key => $value){
if (isset($_POST[$key]) && ($_POST[$key] != '')) {
$content = preg_replace("/\{(key+)\}/", $value, $content);
}
}
if(strpos($content, '{key}') !== false)
return $content='';
else
return $content;
}?>
<form method="post">
<input type="text" name="color" />
<input type="text" name="gh" />
<input type="submit" />
</form>
If you want first color check then try
if (isset($_POST['color']) && ($_POST['color'] != '')) {
$content = preg_replace("/\{(key+)\}/", $value, $content);
}
elseif (isset($_POST[$key]) && ($_POST[$key] != '')) {
$content = preg_replace("/\{(key+)\}/", $value, $content);
}
I understand that you really need the function and not just 'inline' code. In that case, this function will do the trick (if I understand your wishes correctly).
In the comments of the code you will find some guidance.
Hope this helps :)
function sentenceBuilder($content = '')
{
preg_match_all('/\{(.*?)\}/', $content, $matches); // Find all {...} matches
$valueMissing = false; // If a POST value is missing, this will be set to TRUE
if(isset($matches[0]) && !empty($matches[0])) { // Braces are found
foreach($matches[0] as $id => $match) {
// Note the usage of $matches[0] vs $matches[1]: $matches[0] = '{animal}','{land}', while $matches[1] = 'animal','land' without the braces
$key = (isset($matches[1][$id]) ? $matches[1][$id] : false); // Quick if/else
$postValue = ($key != false ? (isset($_POST[$key]) ? $_POST[$key] : false) : false); // Quick if/else (double)
if($postValue == false) {
$valueMissing = true;
break; // Leave the foreach loop
} else {
$content = str_replace($match, $postValue, $content); // Replace the value
}
}
if($valueMissing) {
return ''; // Return empty string (braces found, but not all values were found in the POST)
}
}
return $content; // Return the content
}
-------- ORIGINAL POST --------
The preg-replace seems a bit overkill for this, isset() and empty() will do the trick.
<?php
if(isset($_POST) && !empty($_POST))
{
// Start with empty content
$content = '';
// Only add content (.=) when the field is set (posted) and NOT empty
if(isset($_POST['color']) && !empty($_POST['color'])) {
$content .= "The visitor's favorite color is " .$_POST['color']. "<br/>";
}
if(isset($_POST['animal']) && isset($_POST['land']) && !empty($_POST['animal']) && !empty($_POST['land'])) {
$content .= "The visitor's favorite animal is a " .$_POST['animal']. " from " .$_POST['land']. "<br/>";
}
if(isset($_POST['state']) && !empty($_POST['state'])) {
$content .= "The visitor is from " .$_POST['state']. "<br/>";
}
if(isset($_POST['number']) && !empty($_POST['number'])) {
$content .= "The visitor's favorite number is " .$_POST['number']. "<br/>";
}
// If there is some content, show it
if(!empty($content))
{
echo $content;
}
else
{
echo "Please fill in some values!";
}
}
else
{
?>
<form method="post" action"<?php echo $_SERVER['PHP_SELF']; ?>">
Favorite color: <input type="text" name="color" /><br />
Favorite animal: <input type="text" name="animal" /><br />
from land: <input type="text" name="land" /><br />
<br />
Favorite number: <select name="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="submit" value="SEND this form" />
</form>
<?php }
And you can use HTMLPurifier (for example) to 'filter' any user-input data. http://htmlpurifier.org/
This works.
<?php
if(isset($_POST)){
$content = "The visitor's favorite color is {color}";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor's favorite animal is a {animal} from {land}";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor is from {land}";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor is from Iowa";
echo sentenceBuilder($content);
?> <br/> <?php
$content = "The visitor is from {state}";
echo sentenceBuilder($content);
}
function sentenceBuilder($content){
preg_match("/\{(.*?)\}/", $content, $checkbrackets);
if(!empty($checkbrackets)){
$gettext = str_replace('{', '', $checkbrackets[0]);
$gettext = str_replace('}', '', $gettext);
if(array_key_exists($gettext,$_POST)){
if(!empty($_POST[$gettext])){
$content = preg_replace("/\{($gettext+)\}/", $_POST[$gettext], $content);
}else{
$content = '';
}
}
}
return $content;
}
?>
<form method="post" action"sentencebuilder.php">
<input type="text" name="color" />
<input type="text" name="animal" />
<input type="text" name="land" />
<input type="submit" />
</form>
I have created a PHP form to take 4 text fields name, email, username and password and have set validation for these. I have my code currently validating correctly and displaying messages if the code validates or not.
However, I would like for it to keep the correctly validated fields filled when submitted and those that failed validation to be empty with an error message detailing why.
So far I have the following code, the main form.php:
<?php
$self = htmlentities($_SERVER['PHP_SELF']);
?>
<form action="<?php echo $self; ?>" method="post">
<fieldset>
<p>You must fill in every field</p>
<legend>Personal details</legend>
<?php
include 'personaldetails.php';
include 'logindetails.php';
?>
<div>
<input type="submit" name="" value="Register" />
</div>
</fieldset>
</form>
<?php
$firstname = validate_fname();
$emailad = validate_email();
$username = validate_username();
$pword = validate_pw();
?>
My functions.php code is as follows:
<?php
function validate_fname() {
if (!empty($_POST['fname'])) {
$form_is_submitted = true;
$trimmed = trim($_POST['fname']);
if (strlen($trimmed)<=150 && preg_match('/\\s/', $trimmed)) {
$fname = htmlentities($_POST['fname']);
echo "<p>You entered full name: $fname</p>";
} else {
echo "<p>Full name must be no more than 150 characters and must contain one space.</p>";
} }
}
function validate_email() {
if (!empty($_POST['email'])) {
$form_is_submitted = true;
$trimmed = trim($_POST['email']);
if (filter_var($trimmed, FILTER_VALIDATE_EMAIL)) {
$clean['email'] = $_POST['email'];
$email = htmlentities($_POST['email']);
echo "<p>You entered email: $email</p>";
} else {
echo "<p>Incorrect email entered!</p>";
} }
}
function validate_username() {
if (!empty($_POST['uname'])) {
$form_is_submitted = true;
$trimmed = trim($_POST['uname']);
if (strlen($trimmed)>=5 && strlen($trimmed) <=10) {
$uname = htmlentities($_POST['uname']);
echo "<p>You entered username: $uname</p>";
} else {
echo "<p>Username must be of length 5-10 characters!</p>";
} }
}
function validate_pw() {
if (!empty($_POST['pw'])) {
$form_is_submitted = true;
$trimmed = trim($_POST['pw']);
if (strlen($trimmed)>=8 && strlen($trimmed) <=10) {
$pword = htmlentities($_POST['pw']);
echo "<p>You entered password: $pword</p>";
} else {
echo "<p>Password must be of length 8-10 characters!</p>";
} }
}
?>
How can I ensure that when submit is pressed that it will retain valid inputs and empty invalid ones returning error messages.
Preferably I would also like there to be an alternate else condition for initial if(!empty). I had this initially but found it would start the form with an error message.
Lastly, how could I record the valid information into an external file to use for checking login details after signing up via this form?
Any help is greatly appreciated.
Try using a separate variable for errors, and not output error messages to the input field.
You could use global variables for this, but I'm not fond of them.
login.php
<?php
$firstname = '';
$password = '';
$username = '';
$emailadd = '';
$response = '';
include_once('loginprocess.php');
include_once('includes/header.php);
//Header stuff
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES, "utf-8");?>" method="post">
<fieldset>
<p>Please enter your username and password</p>
<legend>Login</legend>
<div>
<label for="fullname">Full Name</label>
<input type="text" name="fname" id="fullname" value="<?php echo $firstname ?>" />
</div>
<div>
<label for="emailad">Email address</label>
<input type="text" name="email" id="emailad" value="<?php echo $emailadd; ?>"/>
</div>
<div>
<label for="username">Username (between 5-10 characters)</label>
<input type="text" name="uname" id="username" value='<?php echo $username; ?>' />
</div>
<div>
<label for="password">Password (between 8-10 characters)</label>
<input type="text" name="pw" id="password" value="<?php echo $password; ?>" />
</div>
<div>
<input type="submit" name="" value="Submit" />
</div>
</fieldset>
</form>
<?php
//Output the $reponse variable, if your validation functions run, then it
// will contain a string, if not, then it will be empty.
if($response != ''){
print $response;
}
?>
//Footer stuff
loginprocess.php
//No need for header stuff, because it's loaded with login.php
if($_SERVER['REQUEST_METHOD'] == 'POST'){//Will only run if a post request was made.
//Here we concatenate the return values of your validation functions.
$response .= validate_fname();
$response .= validate_email();
$response .= validate_username();
$response .= validate_pw();
}
//...or footer stuff.
functions.php
function validate_fname() {
//Note the use of global...
global $firstname;
if (!empty($_POST['fname'])) {
$form_is_submitted = true;
$trimmed = trim($_POST['fname']);
if(strlen($trimmed)<=150 && preg_match('/\\s/', $trimmed)){
$fname = htmlentities($_POST['fname']);
//..and the setting of the global.
$firstname = $fname;
//Change all your 'echo' to 'return' in other functions.
return"<p>You entered full name: $fname</p>";
} else {
return "<p>Full name must be no more than 150 characters and must contain one space.</p>";
}
}
}
I wouldn't suggest using includes for small things like forms, I find it tends to make a mess of things quite quickly. Keep all your 'display' code in one file, and use includes for functions (like you have) and split files only when the scope has changed. i.e your functions.php file deals with validation at the moment, but you might want to make a new include later that deals with the actual login or registration process.
Look at http://www.php.net/manual/en/language.operators.string.php to find out about concatenating.
I want to preface this question with the fact that I am a student and this is my first PHP class. So, the following question might be a bit novice...
Okay so the point of this program was for me to filter results from a form through regular expressions along with clean up the text area content...
Well as of right now, all works fine except for the strip_tags bit. I have it set to allow the tags <b> and <p>, and when I enter regular text into the text area, it returns perfectly. If I enter something such as <b>lucky</b> you, all that is returned is 'b'.
I'll post my code. If anyone can give me a hand, I'd love it. At this point I'm overly frustrated. I've studied the examples my instructor supplied (mine is almost identical) and I've looked throught the PHP.net manual and from what I read it should work...
The working code is at http://www.lampbusters.com/~beckalyce/prog3b.php
<?php
if ( $_SERVER['REQUEST_METHOD'] == 'GET' )
{
echo <<<STARTHTML
<div class="content"><h1>Site Sign Up</h1>
<h3>Enter Information</h3>
<hr />
<form method="post" action="$_SERVER[PHP_SELF]">
<p>Full Name: <input type="text" name="fullName" size="30" /></p>
<p>Password: <input type="password" name="password" size="30" maxlength="12" /></p>
<p>Email: <input type="text" name="email" size="30"/></p>
<p>Tell us about yourself:<br />
<textarea name="aboutYou" rows="5" cols="40"></textarea><br />
<input type="submit" name="submitted" value="submit" /> <input type="reset" /></p>
</form></div>
STARTHTML;
}
elseif ( $_SERVER['REQUEST_METHOD'] == 'POST')
{
$errors = array();
$dirtyName = $_POST['fullName'];
$filterName = '/(\w+ ?){1,4}/';
if (preg_match($filterName, $dirtyName, $matchName))
{
$cleanedName = ucwords(strtolower(trim(strip_tags(stripslashes($matchName[0])))));
}
else
{
$errors[] = "Enter a valid name. <br />";
}
$dirtyPass = $_POST['password'];
$filterPass = '/[a-zA-Z0-91##$%^&*]{8,12}/';
if (preg_match($filterPass, $dirtyPass, $matchPass))
{
$cleanedPass = $matchPass[0];
}
else
{
$errors[] = "Enter a valid password. <br />";
}
$dirtyEmail = $_POST['email'];
$filterEmail = '/^(?:\w+[.+-_]?){1,4}(?:\w+)#(?:\w+\.){1,3}\w{2,4}/';
if (preg_match($filterEmail, $dirtyEmail, $matchEmail))
{
$cleanedEmail = $matchEmail[0];
}
else
{
$errors[] = "Enter a valid email address. <br />";
}
$dirtyText = $_POST['aboutYou'];
$filterText = '/((\w+)[ ."\'?!,-]{0,3})+/';
if (preg_match($filterText, $dirtyText, $matchText))
{
$validText = $matchText[0];
$ignore = '<b><p>';
$notags = strip_tags($validText,$ignore);
$cleanedText = preg_replace('/fuck|shit|ass|bitch|android/i',"*****",$notags);
}
else
{
$errors[] = "Enter information about yourself. <br />";
}
if (count($errors) == 0)
{
echo <<<STARTHTML2
<div class="content"><h1>Site Sign Up</h1>
<h3>Verify your information</h3>
<hr />
Name: <span class="choices"> $cleanedName <br /></span>
Password: <span class="choices">$cleanedPass <br /></span>
Email: <span class="choices">$cleanedEmail <br /></span>
About you: <span class="choices">$cleanedText <br /></span>
STARTHTML2;
}
else
{
echo "<div class=\"content\">Please correct the following errors:<br />\n";
$errnum = 1;
foreach ($errors as $inderr)
{
echo "$errnum. $inderr";
$errnum++;
}
}
echo '<br />Back to Form';
echo '</div>';
echo '<p style="text-align: center">' . date('l, F d, Y') . '</p>';
}
?>
It doesn't look like your regular expression allows for the < and > characters, also, if it was meant to match the entire text, it should start with ^ and end with $, otherwise it will just match on a small section of the input as best it can according to the pattern which is likely what happened to simply return 'b' in $match[0] when supplying <b>TextHere