61: How to Create a Unique String in PHP | Generate a Key | PHP Tutorial | Learn PHP Programming

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 85

  • @tapiraat331
    @tapiraat331 6 лет назад +12

    Very excited to learn this, thanks for the tutorial! You're the only reason I know anything about PHP in the first place. Keep up the amazing work!

  • @abisother
    @abisother 4 года назад

    Man you can't understand what i'm gaining because of your logics ,you made my life happier ,thank you so much!

  • @coolgamer6458
    @coolgamer6458 6 лет назад

    I am from BANGLADESH and I follow your tutorials regularly.I hope that by following your tutorial one more month I can open my own website.THANK YOU DANIEL

  • @amanchaurasiya6238
    @amanchaurasiya6238 3 года назад +1

    Thank You Sir Ji
    You explaining way is so good,

  • @nielsencs
    @nielsencs 6 лет назад +2

    I love watching your videos! You've helped me get back into programming after a break due to a long illness. Thank you. This, like my last comment, is about a small thing I couldn't help noticing but I don't want you to feel I'm anything but impressed with your work. :)
    Looking at the piece of code introduced around 18:00 :
    if ($row['keystringKey'] == $randStr) {
    $keyExists = true;
    break;
    }else{
    $keyExists = false;
    }
    This would be slightly neater as follows:
    $keyExists = ($row['keystringKey'] == $randStr);
    if ($keyExists) {
    break;
    }
    It is also not necessary to double compare a boolean statement 'if (true == true)' for example in the while loop. Hope this helps someone and once again keep up the good work :)

  • @demmetadesse6231
    @demmetadesse6231 6 лет назад

    I loved your all tutorials. Those all are very helpful for me and my computer science classmates here Ethiopia. Keep it up!

  • @PeterSDHeiss
    @PeterSDHeiss 6 лет назад +1

    Hi Daniel,
    love your courses!
    -> good example 8 keys: you "forgot" to catch the case where all the available keys are already generated and exist in your DB. I guess you'd run into an eternal loop.
    Cheers...

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад +1

      Peter S.D. Heiss Hi Peter :) in this situation I would just make sure that the generated key, is set to a length that would ensure enough combinations for the expected amount of users. It doesn't take a lot of characters to allow plenty of possible keys.

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад +1

      Another solution would be to add additional or duplicate characters/symbols to the list of possible characters in the key. :)

  • @Stoney_Eagle
    @Stoney_Eagle 6 лет назад +2

    Very useful tutorial.
    You are to worried about cutting the video and over explain it a bit. My eyes are focused on the cursor on the screen and only when you stop typing and start waving with your hands I will look at you. Don't worry about cutting in the video, just keep the focus on the story 😉. And if you're worried about people flying towards the comment section about security just say the phrase "bare with me it's just to make the explaining easier, I will change it in the end"
    Referring to a video is cool bro. If you need people to know stuf you already explained just leave the video in the description and point them to it.
    I love your videos and this is just a comment that is intended to help you 👊

  • @stephenifeanyinwakasi3510
    @stephenifeanyinwakasi3510 5 лет назад +1

    God Bless You Man. Thanks for giving us these videos.

  • @chriscox1380
    @chriscox1380 6 лет назад +2

    Recently found your channel and videos, great stuff! Looking forward to catching up on the backlog of videos! Cheers!

  • @hassankrisht718
    @hassankrisht718 5 лет назад

    I like ur ways, every moment I feel u smart I go and hit the like button

  • @dhakprasadupreti6249
    @dhakprasadupreti6249 4 года назад

    Dear, mmtuts, I am from Nepal, Thank You very much for this kinds of great job very easily. Thanks again very much.

  • @osherbenzino1595
    @osherbenzino1595 6 лет назад

    wow ! first time i see your channel and boom! , now i going to start and finish your html and css series and then php and javascript just thanks!

  • @Adam-tl3ps
    @Adam-tl3ps 6 лет назад +3

    Can you show us how to make an MVC in PHP, as well as a video on how to create a social network. I know how to create a social network, it'll just be cool if you did so other people can create something similar, because there's a lack of videos on how to do that. It'll also be a good chance to put skills that you've taught into practice. 👌

  • @DLiberator78
    @DLiberator78 6 лет назад +1

    Another excellent tutorial, this was really useful and it is good that you gave three examples on how to achieve the desired results. I guess this could be used to email temporary links for email activation when creating a sign up screen on a website?

  • @silaex8062
    @silaex8062 6 лет назад +7

    You're a life saver

    • @beaujude9412
      @beaujude9412 3 года назад

      I realize Im kinda randomly asking but does anyone know of a good place to watch new series online?

    • @raidenbenton6216
      @raidenbenton6216 3 года назад

      @Beau Jude I would suggest FlixZone. Just search on google for it :)

    • @jadielcarl9025
      @jadielcarl9025 3 года назад

      @Beau Jude I use flixzone. You can find it on google =)

  • @omarerrabaany6411
    @omarerrabaany6411 6 лет назад

    That was so useful
    it's helped me to continue my project
    Thank you

  • @coolwolfentertainment3174
    @coolwolfentertainment3174 4 года назад

    Thanks for this logic idea.. that learn me a lot 👍👌

  • @arek6296
    @arek6296 2 года назад

    Thanks, I had fun learning this xD

  • @MrTortoed
    @MrTortoed 3 года назад +3

    15:25
    Do NOT do it like that, this is VERY inefficient.
    instead of looping through the array, just add a WHERE word at the end of your query. Mysql does it WAY faster then a php loop

  • @onosekewenu
    @onosekewenu 5 лет назад

    Excellent tutorial! Thank you.

  • @annieesther691
    @annieesther691 4 года назад

    Thank you 🥰

  • @stranger4o4
    @stranger4o4 2 года назад

    amazing tutorial

  • @denisromanov3137
    @denisromanov3137 6 лет назад +1

    Good for you! Ur the MAN!
    At the same time, an example of how you must not write code ...
    Because of such examples - PHP has a bad reputation ...
    So:
    - Optimization of the table structure in the database
    Why do we need `keystringId` ???
    The setting table (innoDb?) For storing unique, text values ​​of a fixed length ...
    - Why iterating through the array of all records in the loop? Shit!
    Selecting all records from the database? Are you serious?
    Try to --- "SELECT `keystringKey` FROM `table` WHERE `keystringKey` = $ randStr LIMIT 1 "
    or generally: SELECT TRUE FROM ... You do not need a value
    - OMG ... Why duplicating the code?
    Try to --- while (($ checkResult = checkKeys ($ randStr)) === true) and keep in memory $checkResult
    Try to --- do {} while ()
    - Why carry around with $conn ???
    What does this shit does in the parameters of the function for STRING GENERATION? Dude!
    Try to --- Use the scope; as a solution - function getConn () {}
    - F**k the console (terminal)! Browser only =)

  • @binzu3215
    @binzu3215 5 лет назад

    Thanks! This helped a lot!

  • @JustKatoh
    @JustKatoh 6 лет назад +2

    an* unique string ;)
    Thanks for the tutorial! Don't take the correction as ill-hearted, love you

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад +5

      Nope it's "a unique" :)
      www.quora.com/Which-is-the-correct-grammar-usage-a-unique-or-an-unique

    • @JustKatoh
      @JustKatoh 6 лет назад +3

      haha, you got me there! Seems like the www.ef.com/english-resources/english-grammar/determiners/ are the culprits

  • @MajidMahdaviNasr
    @MajidMahdaviNasr 2 года назад

    Thank you.

  • @charlesachez7508
    @charlesachez7508 5 лет назад

    love your tutorials and gone through them over and over again. but i am still struggling with form validation. the sample tutorial you had was quite complex with respect to validating username and other fields

  • @venkateshbharadwaj3677
    @venkateshbharadwaj3677 4 года назад +1

    Thank you Very much for the tutorial. It helped me a lot. But when I run the project, I get this error "Notice: Undefined variable: keyexists in C:\xampp\htdocs
    and2\index.php on line 42". How to over come this? Please help me.

  • @nikhilchaudhary8665
    @nikhilchaudhary8665 6 лет назад +3

    *Thank You So Much!!!!! Please Whenever You Get Free Will You Please Make A Video To Do Something That After The User SignsUp He Need To Verify The Email with some verification code or by **_CLICKING_** On the LINK...*

  • @woppysama4901
    @woppysama4901 5 лет назад

    could not Thank you enough !!

  • @saddamalwheeb
    @saddamalwheeb 6 лет назад

    good we can't thank you enough

  • @omalmannapperuma8486
    @omalmannapperuma8486 4 года назад +1

    Great tutorial. Thank you so much.
    I just want to suggest you to make an amendment to function generateKey($conn) coding.
    Since $randstr and $checkKey lines in 3rd and 4th lines of that function gets repeated in the while loop,
    Why not replace those 3rd and 4th lines with only one line
    $checkKey = true;
    Then still while loop should work, isn't it?
    My suggested coding:
    function generateKey($conn) {
    $key Length = 1;
    $str = "abcdefg";
    $checkKey = true;
    while($checkKey == true) {
    $randstr = substr(str_shuffle($str), 0,$keyLength);
    $checkKey = checkKeys($conn, $randStr) ;
    }
    return $randStr;
    }

  • @bozkurtmahmutozdemir9971
    @bozkurtmahmutozdemir9971 6 лет назад

    i watched all php tutorial videos, thanks for tutorials , can you show us how to create rest api in php ?

  • @0jd955
    @0jd955 6 лет назад

    Could you do a tutorial on how to make a news section in a website using databases? Please! This would be really helpful, as there is 0 solutions on google at the moment!!

  • @amoghdatar2726
    @amoghdatar2726 6 лет назад +1

    *_Thank_** You!!!!!!!!!!!!!!!!!!!!!!!*

  • @electronicheartbreak.
    @electronicheartbreak. 6 лет назад

    Another great video! :)

  • @Programming_with_Solo
    @Programming_with_Solo Год назад

    Hi Dani can you create a calclulator that perform arithmetics to numbers as strings in php. mind that php doesnt compute arithmetics on string unlike java

  • @shub8863
    @shub8863 5 лет назад

    Great

  • @TomaSKo156
    @TomaSKo156 6 лет назад

    Love this tutorials

  • @Myfunnyhours
    @Myfunnyhours 2 года назад

    Is it possible to create group of different unique ID like phrases

  • @SerifcanOnursal
    @SerifcanOnursal 3 года назад

    Hi, im a designer, i have no clue about coding but i curious about one thing. How can i do like first member id is @1, second is @2 and goes on like that. How can i do it?

  • @woit472
    @woit472 3 года назад

    You are Love

  • @crazyfiretv7010
    @crazyfiretv7010 4 года назад

    How do i generate a random unique id up login as a user for the first time, and keep that number that generated, so when login again it would remain the same

  • @icaras12x87
    @icaras12x87 5 лет назад

    I don't get something... Minute 17:59 So the break stops the function from running.... after break shouldn't we call again generateKey() in order to generate a new key?

  • @tor0most3r47
    @tor0most3r47 6 лет назад

    thanks

  • @Roabie
    @Roabie 4 года назад

    So, after you generate this code... How do you actually insert it into the database... I am trying to be able to generate unique user ID... So, I already have a website form... and I am able to fill out the form on my website... and in my file manager, I have a php file which then receives the data from the form, then emails it to me... But I also want to be able to insert them into my database.

  • @KpopDriod
    @KpopDriod 6 лет назад +1

    can you make a tutorial about how to create a custom id in database?

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад

      What do you mean? Typically when you create a database table, each row gets their own IDs if you set it up correctly. And in this video i show how to create a unique string that could be used as a long custom ID, if that is what you mean. :)

  • @sunilpandya7242
    @sunilpandya7242 4 года назад

    Is This key remains one and the same, or keep changing, that is to say in Person Address Table it is possible that there are two identical names that is if My Name is Sunil Pandya and My details, some else who's the name also will be Sunil Pandya but his address will be different, email id will be different. To Not to create chaotic situation Person Address table will have unique Id, User of this table, if wish to query, will have to enter this unique id, Can Key generated by Random or Unique id be used, the ID should not change again and again after saving in Database Table

  • @bb6able
    @bb6able 6 лет назад

    Thanks very much for the tutorial.
    A very useful tutorial.
    Hope there will be a video on how to do same using mysqli prepared statement (mysqli_stmt class) and also hope there will be a video for sending email verification code, linking upto one of the login/signup system videos on your youtube channel.

  • @mr.RAND5584
    @mr.RAND5584 4 года назад

    I need to create a link for registration page after registration that link will be deleted. Thanks.

  • @nikamgaloblishvili7305
    @nikamgaloblishvili7305 6 лет назад

    Can you make tutorial about shopping cart ?

  • @franktugume5364
    @franktugume5364 5 лет назад

    hello how do i to i insert the randomly generated keys into a database?

  • @nikeonik8126
    @nikeonik8126 4 года назад

    thanks very much sir,
    after trying the code it worked. but i keep having as this message "that $keyExists" is not defined. so how can i fix that.
    and also please sir how can i make this code echo on a web page in an input for the user to see it as he fill the form before sending to database.

  • @nomanalisiraj8217
    @nomanalisiraj8217 6 лет назад +1

    another awesome video
    want to know how to send email

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад

      I have a video on sending emails in my HTML course and PHP course :)

  • @ezbxz549
    @ezbxz549 6 лет назад

    hey mmtuts I'm about to make an php code that generate a product key in to my database for my c++ program that I created could you help me out to make the key generate once a user sign up on my webbsite

  • @smellypengu1668
    @smellypengu1668 6 лет назад

    Hey, i am working on a website, i would really appreciate if you made a tutorial episode/series on how to make a forum. :D

  • @dc4rts766
    @dc4rts766 4 года назад

    how about uniqid() with md5 and salt is that safe?

    • @DavidAshby1
      @DavidAshby1 3 года назад

      not for anything you need in connection with any kind of security

  • @meowcat2363
    @meowcat2363 5 лет назад

    Hi sir can you teach us how to generate code and save into a file after click a button?

    • @meowcat2363
      @meowcat2363 5 лет назад

      i currently successful save into new file, but could not click to generate code, all i did only can enter text manually

  • @Sudheerkumar-xw3cf
    @Sudheerkumar-xw3cf 5 лет назад

    this code not working, iam not getting unique string

  • @gowthams8340
    @gowthams8340 6 лет назад

    waiting for Codeigniter tutorial series

  • @kathleenfaithromasanta7139
    @kathleenfaithromasanta7139 4 года назад

    it says undefined variable conn?

  • @akshayrana4227
    @akshayrana4227 5 лет назад

    Hello sir,
    Just make a video on advance login system in which session is not expired after browser window is closed by use of cookies like fb, instagram login system.
    Please

  • @nozem1475
    @nozem1475 6 лет назад

    maybe cool to make a toturial php chatting site with php, its not that hard.

  • @ibnuaffan1460
    @ibnuaffan1460 5 лет назад

    How do I create a list number/password of up to 1 million data? anyone know?

  • @sophiawallace5787
    @sophiawallace5787 5 лет назад

    black background on tutorial video is eye straining. Why most tutorial video makers prefer black background display alongside red or dark toned colors for letters. Whether lesson is good, eye straining visibility makes it like watching 1890's movie. Visibility of video through youtube is really not as same as working on black background IDE directly on personal computer.

    • @Dani_Krossing
      @Dani_Krossing  5 лет назад +1

      Actually, the opposite of what you are saying has been proven to be straining for the eyes :) White backgrounds tires the eyes faster which is why experts say to use dark backgrounds when looking at a screen for an extended amount of time. This is why nearly all text editors have black backgrounds by default.

    • @sophiawallace5787
      @sophiawallace5787 5 лет назад

      I think you didn't get the point. Dark background is probably better when directly working on personal computer. But when watching video of recorded black or dark IDE, the visibility becomes indirect or its quality gets low. You can simply see the difference while watching youtube. The difference is obvious when you move your eyes over youtube videos with written text on black background and then switch to the texts on white background or even texts on computer.

  • @Zhak7
    @Zhak7 6 лет назад +1

    I didn't learn anything new but thanks anyway.