Ad block is installed and active. Please support us by disabling it.
HomeFriday, September 22, 2017, 00:42:01
1

Inserting form data in MySql table

Tuesday, February 10, 15, 13:19:42, 3 Yaers Ago Via wain, Hits: 2617
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

Addslashes - Stripslashes

addslashes — quote string with slashes, stripslashes — un-quotes a quoted string

Contact Us Form With Captcha

A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website. Features: Captcha Image, HTML output.

PHP Form Basic

PHP Form - PHP form basic, Requirement(s): PHP Server

Adsense crawler errors and robots.txt

How to fix Google AdSense crawler errors in robots.txt

Convert pdf to image - mpdf

Convert pdf file to jpg with php and mpdf

Password Protect With PHP

Password protect tith PHP - tutorial

Creating a basic bad word filter in PHP

This tutorial will show you how to create a basic bad word filter in PHP

PHPBB3 Shoutbox

Vesion: 1.1. Released: 08/08/10, Licence GNU, Price: Free

Timed Redirect JavaScript

Timed redirect javaScript/PHP example

PHP Redirect

Header (location) redirect must be processed before any output to the browser.
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.