bgbs Posted November 10, 2009 Share Posted November 10, 2009 I would like to wrap all Error messages in one <div> block. Where do I began the DIV tag and where do I end it? if (!empty($_POST['action'])) { $action = $_POST['action']; $passwordExisting = $_POST['passwordExisting']; $passwordNew = $_POST['passwordNew']; $passwordConfirm = $_POST['passwordConfirm']; } if ($action == "change") { if (empty($passwordExisting) ) { $errors .= "<p>» You didn't enter your Existing Password</p>"; } if (empty($passwordNew)) { $errors .= "<p>» You didn't enter a New Password</p>"; } if (empty($passwordConfirm)) { $errors .= "<p>» You didn't enter a Confirmed New Password</p>"; } if ($passwordConfirm != $passwordNew) { $errors .= "<p>» Your New Password and Confirmed Password Do Not Match.</p>"; } $p_user = $db->get_row("SELECT first_name FROM user WHERE uvar = '$uvar' AND pass='$passwordExisting'"); if (empty($p_user->first_name)) { //password is wrong $errors .= "» You entered the wrong Exiting Password. <p><a href='../forgot.php'>If you forgot your existing password, click here.</a></p>"; } else { // user does exist, set cookie and redirect if (empty($errors)) { $db->query("UPDATE user SET pass = '$passwordNew' WHERE uvar = '$uvar'"); $success = "<div class='updated-message'>Your password has been changed.</div>"; $passwordExisting = ""; $passwordNew = ""; $passwordConfirm = ""; } } Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/ Share on other sites More sharing options...
MadTechie Posted November 10, 2009 Share Posted November 10, 2009 just concatenate it where ever you echo the $errors. Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955221 Share on other sites More sharing options...
mikesta707 Posted November 10, 2009 Share Posted November 10, 2009 just wrap the div tags around the variable itself. before you echo $error do $error = "<div>" . $error ."</div>"; edit: ahh sorry, too late. Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955222 Share on other sites More sharing options...
bgbs Posted November 10, 2009 Author Share Posted November 10, 2009 You mean where I output the error? If I put this: <?PHP $error = "<div>" . $error . "</div>"; ?> then it doesnt work. the div box and Errors dont appear at all. Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955230 Share on other sites More sharing options...
mikesta707 Posted November 10, 2009 Share Posted November 10, 2009 well you obviously have to echo it... Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955236 Share on other sites More sharing options...
bgbs Posted November 10, 2009 Author Share Posted November 10, 2009 See, I dont understand any other language accept for english. I can do simple echo. But I dont know how to echo your statement, that is beyond my ability to understand. Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955240 Share on other sites More sharing options...
mikesta707 Posted November 10, 2009 Share Posted November 10, 2009 ? echo $error; ????? im confused, how did you echo $error before? Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955242 Share on other sites More sharing options...
Zane Posted November 10, 2009 Share Posted November 10, 2009 What we're all simply trying to tell you here... in a copy and paste sort of way is: Instead of this $error = "" . $error .""; use this echo "" . $error .""; Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955247 Share on other sites More sharing options...
bgbs Posted November 10, 2009 Author Share Posted November 10, 2009 originally I'm outputting it like this <?PHP echo $errors; ?> But, if I understand you correctly, you want me to out put like this: <?PHP echo "<div class='error-message'>" . $error ."</div>"; ?> which only outputs div Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955249 Share on other sites More sharing options...
bgbs Posted November 10, 2009 Author Share Posted November 10, 2009 oops, I guess it should have been $errors not $error Thanks guys, it works now. I appreciate your help. Link to comment https://forums.phpfreaks.com/topic/181041-solved-where-do-i-add-to-php-code/#findComment-955250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.