bamfon Posted February 3, 2010 Share Posted February 3, 2010 Hi i kind need help on this lil thing. i got a form hooked up to a database so when some one enters there info it save it to the database. i was wondering how would i able to make the database also save the date(not the time just the date). as well What i got so far is <form action="submit.php" method="post" name="form1" class="bkn" id="form1"> <p> </p> <h2><span class="nkb">Title</span><br /> <textarea name="Title" cols="100" class="bkn" width="500" height="50"></textarea> <br /> <span class="nkb">Type</span><br /> <textarea name="Type" cols="100" class="bkn" width="500" height="50"></textarea> <br /> <span class="nkb">Year</span><br /> <textarea name="Year" cols="100" class="bkn" width="500" height="50"></textarea> <br /> <span class="nkb">Genre</span><br /> <textarea name="Genre" cols="100" class="bkn" width="500" height="50"></textarea> <br /> <span class="nkb">Status</span><br /> <textarea name="Status" cols="100" class="bkn" width="500" height="50"></textarea> <br /> <span class="nkb">Summary</span><br /> <textarea name="Summary" cols="100" class="bkn" width="500" height="50"></textarea> <br /> <span class="nkb">pic</span><br /> <textarea name="pic" cols="100" class="bkn" width="500" height="50"></textarea> </h2> <p> <label> <input name="button" type="submit" class="bkn" id="button" value="Submit" /> </label> </p> </form> and on the php submit page i have got <?php $con = mysql_connect("localhost","*****","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****", $con); $sql="INSERT INTO anime (Title, Type, Year, Genre, Status, Summary, pic) VALUES ('$_POST[Title]','$_POST[Type]','$_POST[Year]','$_POST[Genre]','$_POST[status]','$_POST[summary]','$_POST[pic]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> and on the database i have got this Field Type ID int(11) Title varchar(15) Type varchar(15) Year int(11) Genre varchar(15) Status varchar(15) Summary varchar(15) pic varchar(15) dataadd date thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/190778-hi-i-kind-need-help-on-this-lil-thing/ Share on other sites More sharing options...
JonnoTheDev Posted February 3, 2010 Share Posted February 3, 2010 Create another field in your database table to hold the date (make it of date type) i.e dateposted and add the following to your insert query $sql="INSERT INTO anime (Title, Type, Year, Genre, Status, Summary, pic, dateposted)VALUES('$_POST[Title]','$_POST[Type]','$_POST[Year]','$_POST[Genre]','$_POST[status]','$_POST[summary]','$_POST[pic]',CURDATE())"; Quote Link to comment https://forums.phpfreaks.com/topic/190778-hi-i-kind-need-help-on-this-lil-thing/#findComment-1006015 Share on other sites More sharing options...
Bottyz Posted February 3, 2010 Share Posted February 3, 2010 you could use neil.johnsons way above or insert date using an additional variable and use the following: $dateposted = date("Y-m-d"); should give you the year, month and day then add $dateposted into your query Quote Link to comment https://forums.phpfreaks.com/topic/190778-hi-i-kind-need-help-on-this-lil-thing/#findComment-1006017 Share on other sites More sharing options...
bamfon Posted February 3, 2010 Author Share Posted February 3, 2010 Thank you neil.johnson it work well Quote Link to comment https://forums.phpfreaks.com/topic/190778-hi-i-kind-need-help-on-this-lil-thing/#findComment-1006030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.