Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Form problems

  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form problems

    Not sure. It puts everything I need in the Database but it shows undefined constant in my INSERT.

    PHP Code:
    <?php
     
    if (isset($_POST['submit'])) {

      
    // process form

      
    $sql "INSERT INTO content (topicname,content,name,date) VALUES ('".$_POST[topic]."','".$_POST[content]."','".$_POST[name]."','".$_POST[date]."')";

      
    $result mysql_query($sql);

      echo 
    "Thank you! Information entered.\n";

    } else{



      
    // display form



      
    ?>

            <div class="post" id="1">
                <h2>Welcome</h2>
                <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">

                    Topic name:<input type="Text" name="topic" id="topic"><br />

                    Message:<input type="Text" name="content" id="content"><br />

                    Username:<input type="Text" name="name" id="name"><br />

                    Date:<input type="Text" name="date" id="date"><br />

                    <input type="Submit" name="submit" value="Enter information">

                </form>
            </div>
    <?php
    // end if
    ?>
    Also a time for when the post was posted would be nice

    Thanks advanced,
    Metsuo

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    The constant error means you should put the array's index names in quotes eg.
    $_POST['topic']

    As for the current time
    You can either use datetime/timstamp filed and mySQL's NOW() function or an INT(11) filed and PHP's time() function.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #3
    Regular Coder
    Join Date
    Sep 2004
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I knew it was something stupid :P

    Thank you so much!


  •  

    Posting Permissions

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