PHP echo different locations on a page -
i have made form outputs error messages if have not write in right stuff in right places.
i got 4 fields. username, last_name, first_name , email. when haven't written in right stuff in right field outputs error here:
if($validation->fails()) { //here } else { echo 'everything okay!'; }
example:
- that username taken.
- the email not valid.
all of errors gets output in on place. don't want that. want the errors output under each field not in 1 place.
this error groups:
echo '<div class="error_message">',($validation->errors()->all('username')), '</div>';
echo '<div class="error_message">',($validation->errors()->all('last_name')), '</div>';
echo '<div class="error_message">',($validation->errors()->all('first_name')), '</div>';
echo '<div class="error_message">',($validation->errors()->all('email')), '</div>';
this code outputs errors in 1 place:
echo '<div class="error_message">', ($validation->errors()->all()), '</div>';
so question how output 4 error groups on 4 different places?
at place want display $error1
, put:
if ($error1) { echo $error1; }
do same thing other errors , appropriate place.
Comments
Post a Comment