cryptonim Posted February 11, 2011 Share Posted February 11, 2011 hello, I want to display the echo ''"; in the right place on my website in changepassword_form.html all messages are written in changepassword.php. how can i move these echo after entering the wrong password or username? changepassword.php <?php ........... //success //change password in db $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$username'"); session_destroy(); echo 'Password Has Been Changed Successfully !'; //move these } else{ echo('new password doesnt match!'); //move these } } else { die('old password doesnt match!'); //move these } } else { echo ""; include 'changepassword_form.html'; exit(); } } else{ echo 'you must be logged '; } ?> move these echos somewhere to my html code how to do these?? Link to comment https://forums.phpfreaks.com/topic/227405-how-to-display-the-echo-in-a-different-place-on-my-website/ Share on other sites More sharing options...
Pikachu2000 Posted February 12, 2011 Share Posted February 12, 2011 This has nothing to do with PHP math; moving thread to PHP coding help. Also, it's quite unclear what you're actually trying to accomplish :/ Link to comment https://forums.phpfreaks.com/topic/227405-how-to-display-the-echo-in-a-different-place-on-my-website/#findComment-1173058 Share on other sites More sharing options...
acefirefighter Posted February 12, 2011 Share Posted February 12, 2011 I think this might work for you. It may take a little bit to integrate into you existing html but you will get it. If my code doesn't work don't shoot me. The basic idea is to put all of your error messages into a single array and then loop through that array and echo them all at the top of the new page. <?php //success //change password in db $errors = array(); $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$username'"); session_destroy(); array_push($errors,'Password Has Been Changed Successfully !'); //move these } else{ array_push($errors,'new password doesnt match!'); //move these } } else { array_push($errors,'old password doesnt match!'); //move these /* * might want to remove this and redirect the user backto the form * instead of killing the page. */ die('old password doesnt match'); } } else { echo ""; include 'changepassword_form.html'; exit(); } } else{ echo 'you must be logged '; } ?> <html> <body> <?php (isset($errors) ??> <div style="width:100%;bgcolor:red;"> <?php $i = 1; foreach ($errors as $error){ echo $i . ' ' . $error . '<br />'; $i++; });?> </div> <div> <!-- all of your HTML here --> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/227405-how-to-display-the-echo-in-a-different-place-on-my-website/#findComment-1173061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.