PHP Guestbook

Discussion in 'Software' started by [email protected], May 15, 2013.

  1. patriic48@gmail.com

    [email protected]

    Joined:
    Oct 13, 2012
    Messages:
    9
    Likes Received:
    0
    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
    [email protected], May 15, 2013
    #1
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.