August 15, 2018

How to add data to My SQL through PHP

freewaredownload.in free PHP MYSQL SCRIPTS

PHP SCRIPT SOURCE CODE FREE

How to add data to My SQL through PHP

PHP SQL DB FREE SCRIPTS

Source Code for PHP insert Script (Save as insert.php)


<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_dbname", $con);

$sql="INSERT INTO TABLENAME (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con);
?>

Source Code for HTML FORM (save as form.htm)


<html>
<body>

<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>

Developers Homepage Download Free now

 FREE PHP CODE

Description:

SQL

The PHP Source code is used to connect to a MySQL Database using a DB username and a password and select a table and get values from a HTML Form and insert the data in to the respective fields of the open Table. The HTML script gives example of the Form which is used by end user to fill the data for submission to the MySQL DB. You can add Javascript validation to the HTML form or beautify it with proper CSS.

Note: Copy the Source Code to notepad or any other good text editor and save as .php or .html or .css as the case may be. Give your own file name, if not described in the script.

SQL

RELATED FREEWARES

[catlist id=18]
[catlist id=5]

::