如何将数据发送到我的数据库 [英] How to I send data in to my database

查看:90
本文介绍了如何将数据发送到我的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php 
include(connection.php);
?>
<!DOCTYPE html>
< html>
< head>
< title>主页(酒店管理)< / title>
< link rel =stylesheettype =text / csshref =css / style.css>
< link relhref =img / HDlogo.jpgtype =img / iconrec =icon>
< / head>
< body>
< div id =full>
< div id =bgstyle =background-image:url('img / bed.jpg'); height:1200px;>
< div id =header>
< div id =logo>
< h1>< font color =white>我的项目< / font>< / h1>
< / div>
< div id =nav>
< ul>
< li>< a href =#>主页< / a>< / li>
< li>< a href =#>与我们联系< / a>< / li>
< li>< a href =#>预订我的预订< / a>< / li>
< li>< a href =#>我们的酒店< / a>< / li>
< li>< a href =#>帮助< / a>< / li>
< / ul>
< / div>
< / div>
< div id =banner>
< div id =form>
< form action =room.phpmethod =post>
< table style =color:yellow;>

< tr>
< td>房间号< / td>
< td>< input type =textname =rnoplaceholder =Enter Room Notitle =Enter Room No>< / td>

< / tr>

< tr>
< td>房间类型< / td>
< td>< input type =textname =typeplaceholder =Enter Room Typetitle =Enter Room Type>< / td>

< / tr>
< tr>
< td>房价< / td>
< td>< input type =textname =priceplaceholder =Enter Room Pricetitle =Enter Room Price>< / td>

< / tr>
< td>
< td>< input style =width:80px; height:30px; border-radius:20px; opacity:0.7; type =submitname =submitvalue =submit>< / td>
< / td>

< / table>
< / form>
<?php
if(isset($ _ POST ['submit']))
{
$ rno = $ _ POST ['rno'];
$ type = $ _ POST ['type'];
$ p = $ _ POST ['price'];
if(mysqli_query($ a,插入房间(rno,类型,价格)VALUES('$ rno','$ type','$ p')))
{
echo数据插入;
}
其他
{
echo数据未插入;
}
}

?>
< / div>
< / div>
< / div>
< / div>
< / body>

< / html>





这是连接



<?php 
$ a = mysqli_connect('localhost','root','','hd');
?>





我尝试过:



<?php 
include(connection.php);
?>
<!DOCTYPE html>
< html>
< head>
< title>主页(酒店管理)< / title>
< link rel =stylesheettype =text / csshref =css / style.css>
< link relhref =img / HDlogo.jpgtype =img / iconrec =icon>
< / head>
< body>
< div id =full>
< div id =bgstyle =background-image:url('img / bed.jpg'); height:1200px;>
< div id =header>
< div id =logo>
< h1>< font color =white>我的项目< / font>< / h1>
< / div>
< div id =nav>
< ul>
< li>< a href =#>主页< / a>< / li>
< li>< a href =#>与我们联系< / a>< / li>
< li>< a href =#>预订我的预订< / a>< / li>
< li>< a href =#>我们的酒店< / a>< / li>
< li>< a href =#>帮助< / a>< / li>
< / ul>
< / div>
< / div>
< div id =banner>
< div id =form>
< form action =room.phpmethod =post>
< table style =color:yellow;>

< tr>
< td>房间号< / td>
< td>< input type =textname =rnoplaceholder =Enter Room Notitle =Enter Room No>< / td>

< / tr>

< tr>
< td>房间类型< / td>
< td>< input type =textname =typeplaceholder =Enter Room Typetitle =Enter Room Type>< / td>

< / tr>
< tr>
< td>房价< / td>
< td>< input type =textname =priceplaceholder =Enter Room Pricetitle =Enter Room Price>< / td>

< / tr>
< td>
< td>< input style =width:80px; height:30px; border-radius:20px; opacity:0.7; type =submitname =submitvalue =submit>< / td>
< / td>

< / table>
< / form>
<?php
if(isset($ _ POST ['submit']))
{
$ rno = $ _ POST ['rn'];
$ type = $ _ POST ['type'];
$ p = $ _ POST ['price'];
if(mysqli_query($ a,插入房间(rno,类型,价格)VALUES('$ rno','$ type','$ p')))
{
echo数据插入;
}
其他
{
echo数据未插入;
}
}

?>
< / div>
< / div>
< / div>
< / div>
< / body>

< / html>

解决方案

_POST ['submit']))
{

RNO =

_POST [ 'RNO'];

<?php
include("connection.php");
?>
<!DOCTYPE html>
<html>
<head>
	<title>Home (Hotel Management)</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link relhref="img/HDlogo.jpg" type="img/icon" rec="icon">
</head>
<body>
	<div id="full">
		<div id="bg" style="background-image: url('img/bed.jpg'); height: 1200px;">
		<div id="header">
			<div id="logo">
				<h1><font color="white">My Project</font></h1>
			</div>
			<div id="nav">
				<ul>
					<li><a href="#">Home</a></li>
					<li><a href="#">Contact Us</a></li>
					<li><a href="#">Book My Reservation</a></li>
					<li><a href="#">Our Hotel</a></li>
					<li><a href="#">Help</a></li>
				</ul>
			</div>
		</div>
		<div id="banner">
			<div id="form">
				<form action="room.php" method="post">
			<table style="color: yellow;">
				
				<tr>
					<td>Room No</td>
					<td><input type="text" name="rno" placeholder="Enter Room No" title="Enter Room No"></td>
					
				</tr>

				<tr>
					<td>Room Type</td>
					<td><input type="text" name="type" placeholder="Enter Room Type" title="Enter Room Type"></td>
					
				</tr>
				<tr>
					<td>Room Price</td>
					<td><input type="text" name="price" placeholder="Enter Room Price" title="Enter Room Price"></td>
					
				</tr>
				<td>
					<td><input style="width: 80px; height: 30px; border-radius: 20px; opacity: 0.7;" type="submit" name="submit" value="submit"></td>
				</td>

			</table>
		</form>
		<?php
		if(isset($_POST['submit']))
		{
			$rno=$_POST['rno'];
			$type=$_POST['type'];
			$p=$_POST['price'];
			if(mysqli_query($a,"insert into room (rno,type,price) VALUES ('$rno','$type','$p')"))
			{
				echo "data insert";
			}
			else
			{
				echo "Data not Inserted";
			}
		}

		?>
				</div>
		</div>
	</div>
	</div>
</body>

</html>



this is the connection

<?php
$a=mysqli_connect('localhost','root','','hd');
?>



What I have tried:

<?php
include("connection.php");
?>
<!DOCTYPE html>
<html>
<head>
	<title>Home (Hotel Management)</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link relhref="img/HDlogo.jpg" type="img/icon" rec="icon">
</head>
<body>
	<div id="full">
		<div id="bg" style="background-image: url('img/bed.jpg'); height: 1200px;">
		<div id="header">
			<div id="logo">
				<h1><font color="white">My Project</font></h1>
			</div>
			<div id="nav">
				<ul>
					<li><a href="#">Home</a></li>
					<li><a href="#">Contact Us</a></li>
					<li><a href="#">Book My Reservation</a></li>
					<li><a href="#">Our Hotel</a></li>
					<li><a href="#">Help</a></li>
				</ul>
			</div>
		</div>
		<div id="banner">
			<div id="form">
				<form action="room.php" method="post">
			<table style="color: yellow;">
				
				<tr>
					<td>Room No</td>
					<td><input type="text" name="rno" placeholder="Enter Room No" title="Enter Room No"></td>
					
				</tr>

				<tr>
					<td>Room Type</td>
					<td><input type="text" name="type" placeholder="Enter Room Type" title="Enter Room Type"></td>
					
				</tr>
				<tr>
					<td>Room Price</td>
					<td><input type="text" name="price" placeholder="Enter Room Price" title="Enter Room Price"></td>
					
				</tr>
				<td>
					<td><input style="width: 80px; height: 30px; border-radius: 20px; opacity: 0.7;" type="submit" name="submit" value="submit"></td>
				</td>

			</table>
		</form>
		<?php
		if(isset($_POST['submit']))
		{
			$rno=$_POST['rn'];
			$type=$_POST['type'];
			$p=$_POST['price'];
			if(mysqli_query($a,"insert into room(rno, type, price) VALUES ('$rno','$type','$p')"))
			{
				echo "data insert";
			}
			else
			{
				echo "Data not Inserted";
			}
		}

		?>
				</div>
		</div>
	</div>
	</div>
</body>

</html>

解决方案

_POST['submit'])) {


rno=


_POST['rno'];


这篇关于如何将数据发送到我的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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