changing border in php code
i have a form and inside i have one field and one button. when user hit submit button a php script runs.
in php script i am checking error. ex name is too short etc..
now i want to add a red border only if there is a error. if i get to echo"Error - first name..." than i want to set that input field border red. i am not sure how can i do this. any ideas?
index.php
<?php
if(isset($_POST['button']))
{
//check errors
if((strlen($_POST['f_input']) < 2))
{
echo "Error - first name is too short!";
}
else
{
....
}
}
?>
<form action='index.php' method='POST'>
<input type='field' placeholder='first name' id='f_field' name='f_input' />
...
<button type="submit" id='button' name="button" >submit</button>
</form>
52 Minutes
Discussion Span
Related Article: php code encryption
is a PHP discussion thread by opawix that has 4 replies, was last updated 8 months ago and has been tagged with the keywords: php, code, encryption.
hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7
Use css,
if(strlen($_POST['f_input'])<2))
{
echo"<input type='text' class='abc' value='<?php $_POST['f_input'] ?>'>";
}elseif(strlen($_POST['f_input']>2)){
echo"<input type='text' class='def' value='<?php $_POST['f_input'] ?>'>";
}
so your css would be like
.abc{
border-color:red;
}
.def{
border-color:black;
}
TonyG_cyprus
Posting Whiz
312 posts since Dec 2009
Reputation Points: 46
Solved Threads: 39
Skill Endorsements: 2
Question Answered as of 4 Months Ago by
TonyG_cyprus hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7