SitePoint Sponsor

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 76

Thread: Php for kids

  1. #26
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Quote Originally Posted by SilverBulletUK View Post
    Because you differentiate your users by their username, after all, at login you don't ask for their database id and password do you?



    The schema is basically ensuring that each user has a unique username, as it should be.

    SilverB.
    Thanks SilverB, I appreciate your help.

    I have a question about cookie, like the following :

    PHP Code:
    setcookie("loggedin""TRUE"time()+(3600 24));
    setcookie("mysite_username""$username"); 
    just to be sure, as I understand alone that this line will keep the cookie ( loggedin ) for 24 hours ( because each hour = 3600 seconds ), and in case I want to modify it for 10 or 20 days, I will have to modify the number of hours, or thre is an option to add days ??

  2. #27
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    // please don't forget to answer me on my question above too.

    A new question : please check the following code:

    PHP Code:
    if (!isset($_COOKIE['loggedin'])) die("You are not logged in!<br><a href=login.html>log in</a>");
    $mysite_username $HTTP_COOKIE_VARS["mysite_username"]; 
    echo 
    "you are logged in as $mysite_username.<p>"
    I have a problem, why the username doesn't appear in the browser, so when I logged in, welcome message appears like that :

    you are logged in as .

    why ???

  3. #28
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I highly reccomend "Lynda.com.php.with.mysql.essential.training" I learned a lot from Kevin Skoglund.

    Like you, I already knew basics, like echo, print, and more advanced SQL (funny order), but then I learned how to do much more, and now I feel I can make scripts without singularly relying on if.else!

  4. #29
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks cj1, this is what I'm learning now, but to be honest with you, I found that the script is more clear on w3schools.com, Kevin writes the script and show it like he talks to a programmer, not to a new one likes to learn php. I'm in chapter 6 now, so I will see if the things will be better in next chapters.

    I hope from other members to not forget to answer my questions above.

  5. #30
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bbparis View Post
    // please don't forget to answer me on my question above too.

    A new question : please check the following code:

    PHP Code:
    if (!isset($_COOKIE['loggedin'])) die("You are not logged in!<br><a href=login.html>log in</a>");
    $mysite_username $HTTP_COOKIE_VARS["mysite_username"]; 
    echo 
    "you are logged in as $mysite_username.<p>"
    I have a problem, why the username doesn't appear in the browser, so when I logged in, welcome message appears like that :

    you are logged in as .

    why ???
    $HTTP_COOKIE_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_COOKIE_VARS and $_COOKIE are different variables and that PHP handles them as such)
    my mobile portal
    ghiris.ro

  6. #31
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    Videos help you, sure, but they also show you how to make the same mistakes as the author might make, e.g using brackets around echo statements, using alternative blocks, using longer code than neccesary etc.
    Surely you'll pick up bad habits wherever you go, whether a video or an online tutorial. With both you're bound to pick up bad habits (though not always). You can't avoid them.

    I look back at some of my early projects which I built when I was still getting to grips with PHP and getting my head round MySQL and database theory in general. Whilst the programs I made worked, they certainly were not efficient. So to be honest I think you just have to go through that stage of making mistakes.

    As for my learning style, I generally prefer books. Tutorials tend to only give you the ability to create certain things in isolation whereas books have a bigger scope. Although at the same time if you just want a quick answer to something tutorials are better for that. With books you need to set aside time to read them, which is a drawback.
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  7. #32
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ernie1 View Post
    $HTTP_COOKIE_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_COOKIE_VARS and $_COOKIE are different variables and that PHP handles them as such)
    Thanks Ernie1, I little bit understand what you mean, also I did not found where is the problem to fix it ??

    just to explain more, in login.php page, there is the following code :

    PHP Code:
    setcookie("loggedin""TRUE"time()+(3600 24));
    setcookie("mysite_username""$username"); 
    so in this case my $mysite_username is same as $username ??

    Please don't forget that I'm beginner and not expert like you.

  8. #33
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also:
    If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_COOKIE and $HTTP_COOKIE_VARS arrays.

    always use:
    print_r($_COOKIE); to check if variables are set in cookie.
    my mobile portal
    ghiris.ro

  9. #34
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by themightystephen View Post
    Surely you'll pick up bad habits wherever you go, whether a video or an online tutorial. With both you're bound to pick up bad habits (though not always). You can't avoid them.

    I look back at some of my early projects which I built when I was still getting to grips with PHP and getting my head round MySQL and database theory in general. Whilst the programs I made worked, they certainly were not efficient. So to be honest I think you just have to go through that stage of making mistakes.

    As for my learning style, I generally prefer books. Tutorials tend to only give you the ability to create certain things in isolation whereas books have a bigger scope. Although at the same time if you just want a quick answer to something tutorials are better for that. With books you need to set aside time to read them, which is a drawback.
    thanks themightystephen, I respect your opinion, but I can't find an easy book, do you know one ??? show the things likes w3schools.com ( where I understand the relation between php and MySQL in few days ), simple explication + example to understand how they work.

  10. #35
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first book I used was a Sitepoint book - Build Your Own Database Driven Website using PHP and MySQL by Kevin Yank. The book has what you want - an explanation and example to go with it. It's a while since I read it so I can't remember how good the explanations were but I remember finding it extremely useful in getting me going with doing exactly the what the book's title describes - building my own database driven website.
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  11. #36
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks themightystephen.

    I have a question about Notpad++, it's true that it can modify many pages in one time ??

  12. #37
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bbparis View Post
    thanks cj1, this is what I'm learning now, but to be honest with you, I found that the script is more clear on w3schools.com, Kevin writes the script and show it like he talks to a programmer, not to a new one likes to learn php. I'm in chapter 6 now, so I will see if the things will be better in next chapters.

    I hope from other members to not forget to answer my questions above.
    Oh right yeah, well if you are going to participate in talks on Forums in the future, then you will need to know some of the proper terms, such as concatination, functions, etc. etc.

    I personally looked at w3schools first, and then once you read through that you need to move on to the Lynda training... like I said, I already knew basic PHP, most of the terms, and mysql, so it was easy to pick up.

    After you have read w3schools, you NEED to see some proper coding... becuase then you can see some code you might really need... for example you can read about functions on w3schools, but can't see uses, globals, returning globals, and Kevin tells you what $_SESSION does for example (cookies), not just how to code it...

    Also on the topic of bad habits, $HTTP_GET_(SESSION, COOKIE etc) have been changed to $_SESSION etc. and will be removed in the future PHP versions.

  13. #38
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cj1 View Post
    Oh right yeah, well if you are going to participate in talks on Forums in the future, then you will need to know some of the proper terms, such as concatination, functions, etc. etc.

    I personally looked at w3schools first, and then once you read through that you need to move on to the Lynda training... like I said, I already knew basic PHP, most of the terms, and mysql, so it was easy to pick up.

    After you have read w3schools, you NEED to see some proper coding... becuase then you can see some code you might really need... for example you can read about functions on w3schools, but can't see uses, globals, returning globals, and Kevin tells you what $_SESSION does for example (cookies), not just how to code it...

    Also on the topic of bad habits, $HTTP_GET_(SESSION, COOKIE etc) have been changed to $_SESSION etc. and will be removed in the future PHP versions.
    first thanks for your advices, right I have to learn about a lot of codes, I know that this thing will take time, same as Action Script, I'm originally designer.

  14. #39
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I post again my question for all:

    I have a question about Notpad++, it's true that it can modify many pages in one time ??

    I'm trying to keep all my questions in the same post, like that the way will be easy for a future PHP beginner ( like me now ) to find a lot of answers in the same post.

  15. #40
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No body will answer my question about Notpad++

    so let me ask you another question about ( register_globals = on ) in WAMP. it's no problem if I turn it ON ??? sure I know that I can change it from php.ini, but when it was off, I had some probelms like ( NOTICE : Undefined variable : username ) in the following line for example : setcookie("mysite_username", "$username");

    I appreciate all time your help.

  16. #41
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    About your Notepad++ question...if you're asking whether you can have many files open at the same time, then the answer is yes. I use Notepad++. I definitely like it. It's got lots of nifty features and is quite a lightweight application (by lightweight I mean it is quick - it doesn't take a long time to load up).
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  17. #42
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, for your other question about register_globals (taken from the php.ini file itself):

    ; You should do your best to write your scripts so that they do not require
    ; register_globals to be on; Using form variables as globals can easily lead
    ; to possible security problems, if the code is not very well thought of.

    Basically it is best to turn register_globals off and use $_POST and $_GET to retrieve the data received from a previous page. For example, in your case you might need $_COOKIE['username'] instead of $username although I'm not sure.

    See http://www.w3schools.com/PHP/php_get.asp for more information on $_POST and $_GET.
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  18. #43
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by themightystephen View Post
    About your Notepad++ question...if you're asking whether you can have many files open at the same time, then the answer is yes. I use Notepad++. I definitely like it. It's got lots of nifty features and is quite a lightweight application (by lightweight I mean it is quick - it doesn't take a long time to load up).
    no, I did not mean that, because I have this feature in Dreamweaver CS3, but my question concerning the MODIFICATION of many php files for example in one click.

    Think for example you have about 50 php files, they include a php code and I want to modify it in all the files in one click, it's possible ???

  19. #44
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by themightystephen View Post
    Also, for your other question about register_globals (taken from the php.ini file itself):

    ; You should do your best to write your scripts so that they do not require
    ; register_globals to be on; Using form variables as globals can easily lead
    ; to possible security problems, if the code is not very well thought of.

    Basically it is best to turn register_globals off and use $_POST and $_GET to retrieve the data received from a previous page. For example, in your case you might need $_COOKIE['username'] instead of $username although I'm not sure.

    See http://www.w3schools.com/PHP/php_get.asp for more information on $_POST and $_GET.
    hemmm I followed your advice to make the script working without turn register_globals ON, but no way ( I tried many solutions, replace $_GET by $_POST, or by $_REQUEST, and nothing changed ) . also I learned on w3schools.com about $_GET and $_POST, and I found that $_POST more secure than $_GET, and that $_REQUEST replace the both.

    So, for that, I upload my php pages in a ZIP file ( attached to this post ), to ask you and ask all who like to help, if it is possible to make it run properly without turning register_global ON ???

    ZIP file includes simple register and login script.

    Best regards and thanks in advance for you and other php experts.
    Attached Files Attached Files

  20. #45
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really like Zend's PHP 101: PHP For the Absolute Beginner.

    Those tutorials teach all the right things and in my opinion teach them well. I think the articles are very well written and easy to digest.

  21. #46
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by slpshtmike View Post
    I really like Zend's PHP 101: PHP For the Absolute Beginner.

    Those tutorials teach all the right things and in my opinion teach them well. I think the articles are very well written and easy to digest.
    I checked the website and saved the link, give me few days or about one week to give you my feedback, because I found many lessons and I have to check some of them.

    thanks for your help, and welcome to any other members help, comments and advices...really I like this forum.

  22. #47
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi for all, a new question please :

    How can I check the data in a form before post it to the database ??

    there is a simple way to check if the form still empty and show message says ( form empty, please write something ) ??

  23. #48
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    I'm soooo happy to build my first script ( Add Your Link ), you can check it on the following link : www.beginfromhere.com/php/addyourlink/

    bigenfromhere.com is a website that I created just to share my experience in PHP with all who try to learn it like me.

    please let me know your feedback, and till now no body answer me about my question ( register_global ) or checked my script that I attached it to my post in Aug 24, 2008 12:51 , to know how can I build it without turning my register_global ON ???

    Best regards to all, and thanks for each one answered me in this BEST FORUM and tried to make PHP easier for me.

  24. #49
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry I forgot something important about my first script ( Add Your Link ).

    I build also a page to DELETE a link, but I hide it because the website online and it's danger to make it available for public.

    NB: I can send you the link by a Private Message if something interesting to check it.

  25. #50
    SitePoint Evangelist BJ Duncan's Avatar
    Join Date
    Jun 2007
    Location
    North Richmond
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A little late on the thread, but a fantastic resource site for video php is PHP Video Tutorials. The creator of the site is an Aussie guy by the name of LeighMac. This site is absolutely fantastic and he has free lessons (no catches). Highly recommended.
    Regards,
    BJ Duncan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •