<?php
$site = site_url();
$tec = $site;
$tecget = $site . '/';
$tecgetwo = substr($site, 7);
$gett = get_option('FPMobileget');
if (strpos($gett, "http://www.") === 0) {
$gettt = substr($gett, 11);
$getttc = 'http://' . $gettt;
}
elseif (strpos($gett, "www.") === 0) {
$getwww = substr($gett, 4);
$getwwwc = 'http://' . $getwww;
}
elseif (strpos($gett, "http://") === 0) {
$gethttp = substr($gtt, 7);
}
if (($gett == $tec) || ($gett == $tecget) || ($getwwwc == $tec) || ($getttc == $tec) || ($gett == $tecgetwo)) {
echo "you entered the same url";
echo '<div class="error"><p style="color:#F00">Warning -error</p></div>';
delete_option('FPMobileget');
}
else {
echo "success";
}
?>
i want to check user url input with the current site url whether they are same or not,if it is same i want to throw a error message to the user in admin menu simultaneously i want to clear the text field.i used get_option(‘FPMobileget’) to get user input from text-box. so i used delete_option to clear text field when condition satisfy(if url are same).Here user may enter url in different way so i have undergone some string function to take care of that.here all works fine but error messages were displayed on top, but not next to text-box. all works fine here but i want to display the error message next to textbox thats it.this is my first Question in stackoverflow,since i’m new to stackoverflow. Thanks in advance.
Make the whole thing a function, convert your error message a string (not use echo) and use
return $errorstring;
to send the string back to the form.You can then put $errorstring on the form wherever you want.