View Full Version : Form problems

09-04-2005, 01:31 AM
Not sure. It puts everything I need in the Database but it shows undefined constant in my INSERT.

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">
<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">

} // end if

Also a time for when the post was posted would be nice :)

Thanks advanced,

09-04-2005, 01:51 AM
The constant error means you should put the array's index names in quotes eg.

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.

09-04-2005, 02:32 AM
I knew it was something stupid :P

Thank you so much!