PHP Guestbook

Discussion in 'Software' started by patriic48@gmail.com, May 15, 2013.

  1. patriic48@gmail.com

    patriic48@gmail.com

    Joined:
    Oct 13, 2012
    Messages:
    9
    Location:
    Middle Sweden
    Hi there! I get a couple of warning messages:
    Notice: Undefined variable: rad in C:\wamp\www\guestbook.php on line 29
    Notice: Undefined variable: rad in C:\wamp\www\guestbook.php on line 30 Call Stack #TimeMemoryFunctionLocation 10.0017249576{main}( )..\guestbook.php:0 ">

    Don´t know what is wrong with the code, please help!!

    <html>
    <head>
    <title>Guestbook</title>
    <script language="JavaScript">
    function skicka OnClick() {
    var nam=ducument.matain.namn.value;
    var inl=document.matain.inlagg.value;
    var epo=document.matain.epost.value;
    if((nam.length !=0)&&(inl.lebgth !=0)&&(epo.length !=0)) {
    return true;
    }
    else {
    alert("Du glömde fylla i Namn,Epost eller inlägg");
    return false;
    }
    }
    </script>
    </head>
    <body>
    <?
    if(isset($nytt)) {
    matain();
    }
    $lank=mysql_connect("localhost","root","");
    $sql="SELECT * FROM gast ORDER BY datum DESC";
    $result=mysql_db_query("guestbook_db","$sql");
    while($rad=mysql_fetch_array($result)) {
    ?>
    <font face="verdana" size="2"><p><?=$rad["inlagg"]?></p>
    <a href="?>"><?=$rad["namn"]?></a>,<?=$rad["datum"]mailto:<?=$rad["epost"]?>"><?=$rad["namn"]?></a>,<?=$rad["datum"]?>
    <hr>

    <? }
    mysql_close($lank);
    ?>
    <form method="post" action="guestbook.php" name="matain" onSubmit="return skicka_OnClick();">
    Namn:<br><input type="text" name="namn"><br>
    Epost:<br><input type="text" name="epost"><br>
    Inlägg:<br><textarea name="inlagg" rows="5" cols="30"></textarea><br>
    <br><input type="submit" name="nytt" value="Skicka"><input type="reset" value="Återställ">
    <br>
    </form>
    </font>
    <?
    function matain() {
    global $namn,$inlagg,$epost;
    $datum=date("Y-m-d H:i:s");
    $lank=mysql_connect("localhost","root","");
    $databas=mysql_select_db("guestbook_db");
    $sql="INSERT INTO gast(namn,inlagg,epost,datum) VALUES('$namn','$inlagg','$epost',$datum')";
    mysql_query("$sql");
    mysql_close($lank);
    }
    </body>
    </html>

    Regards / patriic
     
    Last edited: May 15, 2013
    patriic48@gmail.com, May 15, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gb

    Guestbook

    gb, Apr 4, 2004, in forum: Computer Support
    Replies:
    4
    Views:
    3,414
  2. raviraj joshi
    Replies:
    0
    Views:
    696
    raviraj joshi
    Jul 4, 2009
  3. EVS
    Replies:
    0
    Views:
    2,120
  4. infocus
    Replies:
    0
    Views:
    928
    infocus
    Jul 19, 2010
  5. EVS
    Replies:
    0
    Views:
    1,971
Loading...

Share This Page