如何使用html表单在mysql数据库中插入数据 [英] How to insert data in a mysql database using a html form

查看:533
本文介绍了如何使用html表单在mysql数据库中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我目前所拥有的



这是html表格



This is what i currently have

This is the html form

<form id="form1" name="form1" method="post" action="includes/facilityProjectIndex.php">
<label for="name_of_facility">Name Of Facility</label><input type="text" name="name_of_facility" id="name_of_facility" />
<br class="clear" /> 
<label for="location">Location</label><input type="text" name="location" id="location" />
<br class="clear" /> 
<label for="responsible_organisation">Responsible Organisation</label><input type="text" name="responsible_organisation" id="responsible_organisation" />
<br class="clear" /> 
<input type="submit" name="Submit" id="Submit" value="Submit" />
<br class="clear" /> 
</form>





这是php索引文件

< br $> b $ b





And this is the php index file



<?php //Facility index file that sends data from the form to the database 
	

include 'connection.php';
	
	// Assigning Variables
	$name = $_POST['name_of_facility'];
	$location = $_POST['location'];
	$responorg = $_POST['responsible_organisation'];	
	
	// Variable that executes request to send data to database 
	$sql = "INSERT INTO facilities (name_of_facility,location,responsible_organisation)
			VALUES('$name','$location','$responorg')";
	
	// Statement stating whether the execution is successful 
	if (!mysqli_query ($link,$sql)){
		die ('Error: ' . mysqli_error($link));
	} 
	else 
		echo ('Entry successfully submitted');
?>







请帮忙!




Any help please !

推荐答案

name =
name =


_POST [' name_of_facility'];
_POST['name_of_facility'];


location =
location =


这篇关于如何使用html表单在mysql数据库中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆