kiến thức tổng hợp
Home
Technology
tip
SOFTWARE
TOOL
WORDPRESS
HEALTH
news
windows
boot
ghost
download
code
android
C#
sql
css
PHP
Blog
ASP
Home
/
PHP
/
Beginner PHP Tutorial - 181- 184 - POSTing Data Part 1-5
13 thg 10, 2015
Beginner PHP Tutorial - 181- 184 - POSTing Data Part 1-5
Thứ Ba, tháng 10 13, 2015
PHP
index.php
<html> <head> <script type = "text/javascript"> function insert() { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject ('Microsoft.XMLHTTP'); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState ==4 && xmlhttp.status == 200) { document.getElementById('message').innerHTML = xmlhttp.responseText; } } parameters ='text='+document.getElementById('text').value; xmlhttp.open('POST','update.inc.php',true); xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xmlhttp.send(parameters); } </script> </head> <body> Insert : <input type ="text" id = "text"><input type = "button" value ="submit" onclick ="insert();"> <div id = "message"></div> </body> </html>
update.inc.php
<?php mysql_connect('localhost','root',''); mysql_select_db('ajax'); if (isset($_POST['text'])) { $text = $_POST['text']; if (!empty($text)) { $query ="INSERT INTO `data` VALUES ('','".mysql_real_escape_string($text)."')"; if ($query_run = mysql_query($query)) { echo 'Data inserted.'; } else { echo 'Failed'; } } else { echo 'please type something!.'; } } ?>
Beginner PHP Tutorial - 181- 184 - POSTing Data Part 1-5
2015-10-13T11:11:00+07:00
Rating:
4.5
Diposkan Oleh:
http://pdunoteit.blogspot.com/
Bài đăng Mới hơn
Bài đăng Cũ hơn
Trang chủ
Lên đầu trang
NEW PICTURE
POPULAR POST
USB-HDD BOOT v2.5 Tạo menu boot cho USB và HDD (hỗ trợ Win 64bit và 32bit)
USB-HDD BOOT là một ứng dụng hỗ trợ người dùng dễ dàng tạo menu boot cứu hộ máy tính đa chức năng cho usb, ổ cứng di động hoặc menu boot...
GÓI CÀI ĐẶT WINDOWS DẠNG ISO
– Nếu người dùng đã có sẳn gói cài đặt dạng iso trên máy thì không cần phải download các gói cài đặt ở bên dưới, chỉ cần download Ứng dụ...
Chuyển dữ liệu dòng thành cột trong SQL
CREATE DATABASE tam GO USE tam GO CREATE TABLE Tbl1(HoTen NVARCHAR(50), MonHoc NVARCHAR(50), Diem INT) GO INSERT INTO Tbl1(HoTen, MonHo...