Results 1 to 14 of 14

Thread: Guestbook

  1. #1
    sly gypsy Recognized Member Levian's Avatar
    Join Date
    May 2002
    Location
    Donut Plains
    Posts
    14,210
    Articles
    1
    Blog Entries
    4
    Contributions
    • Former Cid's Knight
    • Hosted the Ciddies

    Default Guestbook

    I'm trying to make a guestbook and I get these error messages:

    Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /uia/ravn/u2/cshunn05/project_html/guestbook2/addguestbook.php on line 12

    Notice: Undefined variable: name in /uia/ravn/u2/cshunn05/project_html/guestbook2/addguestbook.php on line 15

    Notice: Undefined variable: email in /uia/ravn/u2/cshunn05/project_html/guestbook2/addguestbook.php on line 15

    Notice: Undefined variable: comment in /uia/ravn/u2/cshunn05/project_html/guestbook2/addguestbook.php on line 15
    and this is the relevant part of the code I guess, first line is line 12 and last is 15:

    $datetime=date("y-m-d h:i:s"); //date time

    $sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
    $result=mysql_query($sql);
    If you need more information to solve this just tell me and I'll provide it. I just don't know what information is relevant and not relevant.

    I'm using this page to help me and all code is from there:
    Creating a simple PHP guestbook

    and here's the link to my guestbook:
    http://prosjekt.hia.no/users/cshunn0.../guestbook.php


  2. #2
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    How are you acquiring $name, $email and $comment? i.e. what code is your php file using to grab them from the form?
    Figaro Castle

  3. #3
    Very VIP person Tech Admin Rantz's Avatar
    Join Date
    Apr 2006
    Posts
    17,631
    Articles
    1

    Default

    It basically seems like it wants you to supply a timezone for the date function. The error reporting is most likely set a few notches stricter than you need it, but I'd try adding this line in the beginning of your code:

    date_default_timezone_set('UTC');

    Or if you want to use another default timezone: PHP: List of Supported Timezones - Manual

  4. #4
    sly gypsy Recognized Member Levian's Avatar
    Join Date
    May 2002
    Location
    Donut Plains
    Posts
    14,210
    Articles
    1
    Blog Entries
    4
    Contributions
    • Former Cid's Knight
    • Hosted the Ciddies

    Default

    I don't know exactly how, but it's fixed now ^^


  5. #5
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    Perhaps your provider had something messed up on their end that they fixed?
    Figaro Castle

  6. #6
    sly gypsy Recognized Member Levian's Avatar
    Join Date
    May 2002
    Location
    Donut Plains
    Posts
    14,210
    Articles
    1
    Blog Entries
    4
    Contributions
    • Former Cid's Knight
    • Hosted the Ciddies

    Default

    Nah, I added this to the code and it seemed to do the trick:

    $name = $_POST['name'];
    $email = $_POST['email'];
    $comment = $_POST['comment'];


  7. #7
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    Well then you know how it's fixed.

    If you didn't have code to retrieve the name, email and comment from the form before then it didn't know how to access them. $_POST['x'] will retrieve values when the form's method is "post" and if the form's method is "get" you can use $_GET['x'].
    Figaro Castle

  8. #8
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    As a side note:
    Code:
    $sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
    The values you are inserting into this query are not properly escaped, so someone could inject SQL and mess up your queries. Any strings that will be used in a SQL query should be sent through mysql_real_escape_string first.

    Example:
    Code:
    $sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($email) . "', '" . mysql_real_escape_string($comment) . "', '" . $datetime . "')";
    $result=mysql_query($sql);

  9. #9
    sly gypsy Recognized Member Levian's Avatar
    Join Date
    May 2002
    Location
    Donut Plains
    Posts
    14,210
    Articles
    1
    Blog Entries
    4
    Contributions
    • Former Cid's Knight
    • Hosted the Ciddies

    Default

    Oh, yeah I didn't know how to secure things, I was kinda hoping it wouldn't happen. But I think I understood that, so thanks!

    Also, if I want a navigation and a banner to appear on every page, that's got something to do with css right? Not really sure where to start on this one.


  10. #10
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    You use includes to handle common navigation, banners, etc... You write your source php file for the navigation, then you include it on every page, like this:

    Left-hand navigation source:
    Code:
    <div>
       <a href="pagea.php">Page A</a><br/>
       <a href="pageb.php">Page B</a><br/>
       <a href="pagec.php">Page C</a><br/>
       <a href="paged.php">Page D</a><br/>
    </div>
    And then in some page on your website:
    Code:
    <html>
       <body>
          Maybe some page code stuff here
          <?php include "left-hand navigation file name (navigation.php or whatever)"; ?>
          Maybe other page stuff follows
       </body>
    </html>
    The idea is that you create one file and then you can insert the contents of that file wherever you specify to.
    Figaro Castle

  11. #11
    sly gypsy Recognized Member Levian's Avatar
    Join Date
    May 2002
    Location
    Donut Plains
    Posts
    14,210
    Articles
    1
    Blog Entries
    4
    Contributions
    • Former Cid's Knight
    • Hosted the Ciddies

    Default

    Oh cool, but does the included navigation have to be php, or can it be an html file?


  12. #12
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    It can be an html file, I believe. I've always used php files so I'm not 100% sure, though.
    Figaro Castle

  13. #13
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    It can be HTML as well as PHP.

  14. #14

    Default

    i helped him. case closed :D

Posting Permissions

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