Jump to content

DomMarx

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by DomMarx

  1. Hi Strider64, Thanks for the help friend! I implemented your code, which is much better than what I had. For some reason, I keep getting: '<p class="errText">Password must be at least 8 characters and must contain at least one lower case letter, one upper case letter and one digit</p>' I'll try and figure out why that is. Everything seems to be placed in the right order and the hashing is done at the end of the registration function What i'm aiming to do it check if the fields are empty, else check if the passwords entered are valid using preg_match, then check if password and re-enter password fields match, then move on to next field(city, work, etc.) Just in case, here is how I implemented your code: //checks to see if the password field is empty if (empty($_POST['password']) && empty($_POST['password2'])) { echo 'Please create a password.'; return false; } else{ $pass = $_POST['password']; if(preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $pass) === 0) $errPass = '<p class="errText">Password must be at least 8 characters and must contain at least one lower case letter, one upper case letter and one digit</p>'; } //checks to see if both passwords match. if ($_POST['password'] != $_POST ['password2']) { die('You entered two different passwords.');} else{ echo 'Password must be at least 8 characters and must contain at least one lower case letter, one upper case letter and one digit';} Thanks man!
  2. Thanks for the tip litebearer. It still gives me the same results with preg_match though.
  3. Hey litebearer, I looked into regex and the link you gave me. Thanks a lot for taking the time man! I figured out the basics of regex syntax, and I am now trying to apply it to a password field. Here is what i've written: //checks to see if the password field is empty if (empty($_POST['password']) && empty($_POST['password2'])) { echo 'Please create a password.'; return false; } else{ //if the password field isnt empty, it checks to see that only letters/numbers are used. $pass = $_POST['password']; $goodpass = ereg("/^[a-zA-Z0-9]$/", $pass); if ($goodpass) { //checks to see if both passwords match. if ($_POST['password'] != $_POST ['password2']) { die('You entered two different passwords.');} } else{ echo 'Your password is invalid.';} } But everytime I run the function (try to register a new password), I get the 'Your password is invalid" echo. Does anyone know what i've done wrong? Thanks guys!
  4. Hi Dalecosp, thanks for chiming in! I've been searching the web for a proper way to achieve this, but I really don't know where to start codingwise. Here is what i've got, but it only checks if it exists without checking spaces. $query = "SELECT * FROM `users` WHERE LOWER (`username`) = :username"; $stmt = $dbh->prepare($query); $stmt->bindValue(':username', strtolower($_POST['username'])); $stmt->execute(); if ($stmt->rowCount() > 0) { die('this user is already registered.') ; } I can't seem to find anything on google that directly touches this point.
  5. Hey Guys, I'm currently working on a user registration form and everything is working pretty well, except one major problem. The PHP script sees DavidJones and David Jones as 2 different users. So I was wondering how to go about making the registration script disregard spaces so that users don't end up with the same usernames, only with spaces/no spaces. It would get confusing. So if "David Jones" was already registered and another user was registering as "DavidJones" or "Dav id J ones", then it wouldn't let him. Thanks!
  6. Hi DavidAM, Thanks for the help. I believe I understand what you're saying, except if I shouldn't store images directly in the database, or store the direct path to the images in every single row for the obvious reason you pointed out, where do I place the path?
  7. Hey guys, i've been searching the web trying to figure out the best method of storing images in a database table when it comes to user registration. Basically, users will register with only 3 elements: Upload Image( turned into Avatar/Thumbnail), E-mail, and Password. Now i've figured out the basics on how to store user information such as the e-mail and pass, but I still haven't found any direct answers on the topic of properly managing user avatars/thumbnails. Now these avatars will be displayed everytime the user posts, much like any forum or social network. So, do I store the image itself in the database? Do I store it in a user_avatar file/directory on the server and have a direct link in the table to fetch and display the image? What would be the best method to go about this? I thought about maybe having a table with user_ID, avatar_ID and avatar_link(direct link to image).
  8. jcbones, thanks for chiming in! I'm currently reading up on using indexes, and from what I can grasp so far this seems to be a great tool to connect the user, vote and topic entities as a group for things like results in front-end search queries (if i'm not mistaken). I'll keep reading into it! Psycho, i'll make it a priority to remember to never run queries in loops and to do a search on the topic to understand why. Also, i'll certainly read everything through the Tizag.com links you provided me during the upcoming weekend and check out everything they have on MySQL. gizmola, I re-read your post a couple of times to fully take in the information. I think I understand the basic concept of the tool you are speaking of and it's really intriguing. I'm also looking into this pronto. The engine type is the one thing I haven't played around with in MAMP/PHP Myadmin since really diving into the whole PHP/Mysql world a couple weeks ago, but i'll be sure to use the innodb engine from now on and learn everything about each and every choice in that area. There's so much info to absorb and it's freakin' awesome! Thank you! Thanks guys!
  9. That's exactly what i'll do Psycho. I spent the morning reading some stuff on normalization and JOINs. What I get from this so far, is that everything should connect through IDs. So if that's the case, one would be better off doing something like this: Table 1- Users: User_ID, Username, E-mail, Password, etc... Table 2- Posts: Post_ID, Post_Title, Date_Published, etc... Table 3- Votes: Vote_ID, User_ID, Post_ID. This way I can fetch everything through IDs/Names, generating temporary tables that users can view on the front end when needed without cluttering the database. I'm not saying this is exactly (as i've written it above) the method one should do, i'm just saying that so far from what i've read(only since this morning), this would be a much better/organized way to store/fetch data than having it duplicated in multiple tables. There's still much to learn, and I thank you guys for telling me about this.
  10. Hey Psycho, You're absolutely right. My plan isn't to bombard this forum with a billion questions, so don't worry! I'm reading books, searching the web and watching all the tutorial videos I can. I also want to thank you for answering my question. It really helps. Sometimes the web can give contradicting answers all over the place, so I just felt that by asking here I would have the chance to understand things a little better by asking directly/interacting with someone who knows his stuff. Thanks guys!
  11. Hey requinix, So if the users, topics and votes are separated and placed in different tables in a database on the back-end, you can still represent them as one connected group on the front-end? Meaning, even if they are separated on the back-end, you can still present the registered user with a front-end web page listing the topics they voted on in the past? Much like Facebook and many other sites, I can view all of the posts/topics I or any of my friends/other users have ever liked and can even unlike a topic I have previously liked if I change my mind. The username account is always connected to the votes/topics they made/interacted with within their sessions on the site. So placing each of these elements in different tables has no effect to how they connect in the end? Thanks for taking the time out of your day to respond!
  12. Hey guys, I was thinking about this just now. It would be great to get an idea of how you PHP gurus would handle server organization for something like a Facebook-ish site. No, i'm not trying to build a Facebook haha, but I was wondering, since this could apply to many other situations. Let's say you have a website where users register with their name, e-mail and a password(indeed!). When the users are registered and on the website, they can vote on different posts. Now how would you guys organize this server-side? Would you have a table just for votes, the topics and usernames attached to those votes? Would you have a table per post created with all the users who voted and votes inside? How would you go, or maybe even have gone, about doing this? I'm guessing this is crucial, seeing as how an increase in users and traffic could jam up/crash a server if it's badly organized/set-up. ...and thanks for all the help on here guys. Much better than any other forum i've visited.
  13. That's exactly what I needed Luke! Yeah, I wrote up a function to convert everything. I just needed those 3 lines of code you gave me! Thank you!
  14. Hi requinix, Thanks for the explanation man! I didn't know that. I'll be using this function to get me the "x time ago" since a posted comment. I already wrote up the function to get the number of seconds into x seconds, minutes, days, etc... I just need a way to get me the number of seconds between the date posted and the date viewed(current time/date).
  15. Hi Luke, Thanks for the feedback. I'm having a bit of trouble understanding why we use time();? If it's the time between now and January 1st 1970 in seconds, how would that give me the time between date1 and date2? Let's say I want the time in seconds between right now and 6:43PM June 3rd 2011 in seconds? Not between 1970 and June 3rd 2011 Thanks again man. I appreciate it!
  16. Hey guys, Does anyone know a simple ,clean way of getting the time between a past date and todays date in seconds? I'm trying to figure out what the Linux Timestamp is about. I know it's the time since 1970 to now, but I don't see how I could use that here or why it's used. Perhaps someone could also give me a clue as to what it's mostly used for. THANKS!
  17. I tried the following to experiment, but the Seconds just start over at 0 when reaching 60. Could anyone tell me what is wrong here? <?php $actual_time = date('s'); echo $actual_time." ".'Seconds ago '; if ($actual_time >= 60){ $actual_time = strtotime("+ 1 minute"); echo $actual_time." ".'Minutes ago '; } ?> Also, thanks again for taking the time Barand. This forum is great!
  18. Probably not 50,000 at a time no haha. I meant more along the lines of having 50,000 members and the odds of a group of them (maybe 2,500 users) coincidently posting comments at once/sharing something at the same time.
  19. I also thought i'd ask a quick side question if you don't mind, since you seem pretty knowledgable(being a guru and all haha). When it comes to scalability, does this type of code need to be written differently? Let's say 50,000 users were posting on the website and this type of code was a function to display the comment timestamp, would it eventually break down if it isn't written in a special way? Or does scalability only apply to much larger functions? Just wondering
  20. Thanks Barand i'll try that!
  21. Hey guys, I was just wondering if anyone on here has some guidance for someone trying to build a comment time stamp (30 seconds ago, 1 minute ago, 1 month ago, 1 year ago, etc.) that takes the different day count of every month + leap year into consideration. I'm not asking for you guys to give me straight code or anything. I just need some guidance on finding the proper/best method of going about this. I'm guessing placing everything in arrays is a must? Thanks!
  22. So you don't really need \n then? Unless it's for cleaning up the source code?
×
×
  • 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.