Jump to content

Registration Script


Unholy Prayer

Recommended Posts

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
Share on other sites

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
Share on other sites

  • 2 years later...

...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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.