SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: ack, need help

  1. #1
    SitePoint Zealot honging's Avatar
    Join Date
    Jan 2001
    Location
    Chapel Hill, NC
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ack, need help

    I started learning PHP/mySQL last night...

    I'm trying to get this guesbook thing to work, but I"m having trouble...

    here is the code:

    <HTML>
    <HEAD>
    <TITLE>guestbook</TITLE>
    </HEAD>
    <BODY>
    <p><b>sign the guestbook</b></p>
    <form action="guestbook.php" method="post">
    <b>name</b>: <input type="text" name="name"><br>
    <b>e-mail</b>: <input type="text" name="email"><br>
    <b>website_name</b>: <input type="text" name="website_name"><br>
    <b>website_url</b>: <input type="text" name="website_url"><br>
    <b>AOL Instant Messenger name/b>: <input type="text" name="aim"><br>
    <b>entry</b>: <input type="text" name="entry"><br>
    <input type="submit" name="submission" value="submit">
    </form>
    <?php
    mysql_connect( "localhost", "**", "*****") or die( "server error");
    mysql_select_db( "****") or die( "database error");

    $result = mysql_query("select entry, entry_date, name, email, website_name, website_url, aim, entry_time from gbook");

    while ($row = mysql_fetch_array($result)
    ) {
    $name = $row["name"];
    $email = $row["email"];
    $website_url = $row["website_url"];
    $website_name = $row["website_name"];
    $aim = $row["aim"];
    $entry_date = $row["entry_date"];
    $entry_time = $row["entry_time"];
    $entry = $row["entry"];
    print "<p><a href=\"mailto:$email\">$name</a> <b>[<a href=\"$website_url\">$website_name</a>] [<a href=\"aim://$aim\">$aim</a>]</b> says on $entry_time on $entry_date<br>";
    print "<p>$entry</p>";

    }

    if ("submit" == $submission)
    {
    $sql = "insert into gbook set " .
    "name='$name', " .
    "entry='$entry', " .
    "email='$email', " .
    "aim='$aim', " .
    "website_name='$website_name', " .
    "website_url='$website_url', " .
    "entry_time=curtime(), " .
    "entry_date=curdate()";
    if (mysql_query($sql))
    {
    echo("<p>done</p>");
    }

    else
    {
    echo("<p>not done. failure</p>");
    }
    }
    print "<a href=\"guestbook.php\">refresh to see changes</a>";?>
    </BODY>
    </HTML>

    besides the fact that the thing is ugly as heck, i need some help. in action, the page is at www.neopages.com/roy/php/guestbook.php

    the problem is that it keeps submitting the same variables each time. try it out. no matter what happens, *every* time i submit something, it inputs the original set.

    help?!

  2. #2
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hm, couldn't find any mistakes on a quick look. Please check the table content in phpmyadmin, if it all is "test" than it's a problem of the "INSERT" part, otherwise it's a problem of the output part.

  3. #3
    SitePoint Zealot honging's Avatar
    Join Date
    Jan 2001
    Location
    Chapel Hill, NC
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    phpmyadmin?


  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ignore this.


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
  •