I am new to php just to warn you. Anyway I've looked this up a bunch but seeing as I don't understand too much.. I can't see how to do this.. So I have a table with a 'date' column in it, and I am testing out using a form to insert values into the table.. I wanted to have it so I could split the date up in the form, (eg month: day: year) and have it combine them into one value to insert into the 'date' column.. any ideas how to do this?? I'd tried implode() but I'm not sure exactly how the values are sent from the form so.. With the codes:
The actual form
<form action="submit.php" method="post" style="text-align: center; width: 550px; margin: auto;">
<!--Id: <input type="text" name="id"> -->
<div style="float: left;">Author: <input type="text" name="author"></div>
<div style="float: right;">Month: <input type="text" name="month" size="3">
Day: <input type="text" name="day" size="3">
Year: <input type="text" name="year" size="5"><br></div>
<textarea name="post" style="width: 550px; height: 100px;"></textarea><br>
<input type="submit">
</form>
</body>
the Submit.php
<?php
mysql_connect('localhost','root');
mysql_select_db('apple');
$date = implode("-", "(month, day, year)");
$sql = "INSERT INTO blog (id, author, $date, post) VALUES ('$_POST[id]', '$_POST[author]', '$_POST[date]', '$_POST[post]')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
?>