Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/190778-hi-i-kind-need-help-on-this-lil-thing/
Share on other sites

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())";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.