...

View Full Version : Form problems



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


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

marek_mar
09-04-2005, 12:51 AM
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.

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

Thank you so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum