Unholy Prayer Posted March 14, 2007 Author Share Posted March 14, 2007 Hey, one more problem... How do I make it so that the information isn't inserted into the database if an error message is displayed. Link to comment https://forums.phpfreaks.com/topic/42276-registration-script/page/2/#findComment-206713 Share on other sites More sharing options...
brad Posted March 14, 2007 Share Posted March 14, 2007 by "error message" do you mean the ones for "passwords dont match" etc? Link to comment https://forums.phpfreaks.com/topic/42276-registration-script/page/2/#findComment-206718 Share on other sites More sharing options...
trq Posted March 14, 2007 Share Posted March 14, 2007 One simple method is to set an error flag. <?php $err = false; if (empty($_POST['username'])) { // display error message. echo "No username given"; // set error flag. $err = true; } if (empty($_POST['email'])) { // display error message. echo "No email given"; // set error flag. $err = true; } if (!$err) { // do database insert. } ?> Link to comment https://forums.phpfreaks.com/topic/42276-registration-script/page/2/#findComment-206726 Share on other sites More sharing options...
Unholy Prayer Posted March 14, 2007 Author Share Posted March 14, 2007 Yeah, nvm about that. I actually used a method I learned in my java class where if an error is echoed, it adds 1 to the errors string that was declared before the if statements. So if one error is echoed, the string "$errors" would equal one and so on. Then I used an if statement that would insert the data if $errors = 0. But anyways, thanks for the help everyone. This is my first time making a register script without using a tutorial. Link to comment https://forums.phpfreaks.com/topic/42276-registration-script/page/2/#findComment-206727 Share on other sites More sharing options...
kthxbai2u Posted June 20, 2009 Share Posted June 20, 2009 ...Backticks are not required..... So why does it not work when they are not there and it does when they are there? That to me says that they are needed... And just FYI, you don't know sh*t about me.... Just be happy that I resolved his and my issue... That is what a forum is for. And I think we are all old enough to know when someone says n00b its not to be taken offensively... After all you must be > 13 to sign up. We are not children. Take things easy, don't take them so literally. The attitude comes with the character and I can not stop it. It's part of many disabilities, so if you want to be the one to ban a disabled person with some mental issues... Go ahead. Either forgive me or ban me. Everyone is acting like they have the world up their ass recently... This is why I hate people... I have reason to hate people... I work in their houses all day. I cant stand people... :S Link to comment https://forums.phpfreaks.com/topic/42276-registration-script/page/2/#findComment-859998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.