Ad block is installed and active. Please support us by disabling it.
HomeSaturday, January 20, 2018, 16:54:15
1

Inserting form data in MySql table

Tuesday, February 10, 15, 13:19:42, 3 Yaers Ago Via wain, Hits: 3382
Inserting form data in MySql table with PHP
Example:
Code:
<?php
include ('db_connect.php');
if(isset($_POST['submit']))
{
$data1 = $_POST['data1'];
$data2 = $_POST['data2'];
if (get_magic_quotes_gpc()) {
$data1 = stripslashes($data1);
$data2 = stripslashes($data2);
}
$data1 = mysql_real_escape_string($data1);
$data2 = mysql_real_escape_string($data2);
//This function is used to create a legal SQL string that you can use in an SQL statement. The given string is //encoded to an escaped SQL string, taking into account the current character set of the connection.
$result = mysql_query("INSERT INTO data (data1,data2)
VALUES ('$data1','data2')")
or die(mysql_error());
echo $data1 . ' - ' . $data2 . ' Ok';
}else{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="data1">
<input type="text" name="data2">
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>


Sign In

Sponsor

Related

How to insert new line (IP Address) with fwrite

How to insert new line (IP Address) with fwrite, Get IP address and write to file.

Email to Friend - PHP Script

This form allows your visitors to suggest your site to a friend. It features an HTML email format and an admin notification email.

Meta Tags Generator 1.1. PHP Script

This script will allow your visitors to create meta tags online.

Show / Hide Div with CSS

CSS Display and Visibility:The visibility property specifies whether or not an element is visible.

Comments 1.1. :: PHP Script

This script allows your visitors to add comments to any single page on your web site.

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, Requirement(s): PHP server

Link Base L.1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

Contact Us PHP Form 1.1.

A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

PHP File Create

Create and write data to a file using the php frwite function.

PHP DateTimeZone

PHP representation of time zone
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.