Ad block is installed and active. Please support us by disabling it.
HomeMonday, November 20, 2017, 09:05:44
1

Inserting form data in MySql table

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

Link Base 2.0.

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.

Upload and Resize an Image with PHP

Tutorial - How to upload and resize image with PHP

Random MySQL Query

Random MySQL query, requirement(s): PHP Server, MySQL

PHP form with file upload

Advanced Contact Form with email and form field validation. It allows your visitors to send you an email directly from your website.

Preg_Match - PHP Email Validation

Validate email with preg_match in php

Advanced Contact Form - PHP Script

Advanced Contact Form with email and form field validation. Features: HTML Output(Response), Captcha Image.

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 Array

These functions allow you to interact with and manipulate arrays in various ways. Arrays are essential for storing, managing, and operating on sets of variables.

Stack Overflow Clone Script - Ja2BU

Open source question and answer script written in PHP, MySQL and jQuery. Main features are: SEO friendly url's, private message system, rating system, comments system.

PHP Write to File

PHP Write to File :: PHP Tutorial, requirement(s): PHP server
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.