Posted inTechnology

how to insert date in mysql using php?

For Insert date Into MySQL in ‘dd-mm-yyyy’ format Using PHP first of all I have to make a simple table in data base like bellow example for InsertDate current date in mysql using php.

Insert date Into MySQL Using PHP

how to InsertDate date in mysql using php?
Here i am using main three file for InsertDate data in MySQL Example:

  • database.php:firs of all you can database For connecting & testing data base
  • InsertDate.php:and then for fetching the values from the members
  • process.php:A PHP server side file that process the get data request

Also Read: How to convert date format in PHP?

CREATE TABLE : members

CREATE TABLE `members` (
	`userid` int(8) NOT NULL,
	`member_name` varchar(55) NOT NULL,
	`profile_name` varchar(55) NOT NULL,
	`birth_date` varchar(55) NOT NULL,
	`email` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

database.php


Also Read: Simple PHP Convert Date Format Examples

Alternative Code in (PDO)

setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   $sql = "INSERT INTO members (member_name,profile_name,birth_date,email,datetime)
    VALUES ('$member_name', '$profile_name','$birth_date','$email','$insertdate')";
    $conn->exec($sql);
    echo "New record created successfully";
    }
catch(PDOException $e)
    {

    	echo $sql . "
" . $e->getMessage(); } $conn = null; ?>

InsertDate.php



  
  

how to InsertDate in mysql using php form

First name:

Last name:

Borth Date:

Email Id:


Also Read: How to change date format in PHP?

process.php


I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype