我的第一个php项目有问题, 我这样做是为了自我教育一下。 所以我做了一个表格在这里是代码:
< 加强> vpis.html 强>
<html>
<head>
<title>Php-Web Page - Input</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="glava">
<center>Php Spletna Stran</center>
<hr/>
</div>
<div id="menu">
<center>
<a href="index.php">NAZAJ</a>
<a href="bris.html">BRISANJE</a>
</center>
<hr/>
</div>
<div id ="vsebina">
<div div="vpisigr">
<form action="insert.php" method="post">
Vpisovanje igralca<br/>
ID:<input type="text" name="pid" size="20"/><br/>
Ime:<input type="text" name="pime" size="20"/><br/>
Priimek:<input type="text" name="ppriimek" size="20"/><br/>
Starost:<input type="text" name="pstarost" size="20"/><br/>
Velikost:<input type="text" name="pvelikost" size="20"/><br/>
Polozaj:<input type="text" name="ppolozaj" size="20"/><br/>
ID Kluba:<input type="text" name="ppid" size="20"/><br/>
<input type="submit" value="Shrani"/>
<input type="reset" value="Reset"/>
</form>
</div>
</div>
<hr/>
<div id="footer">
<center>Vse pravice pridržane </center>
</div>
</body>
<html>
所以这里我要求用户输入所有数据插入数据库。 这是数据库的屏幕图集 :
"https://i.sstatic.net/HbMQP.png" alt="数据库图像"/>
此处是“ 加固” 插入.php 强”, 被称为“ 形式行动” 。
<?php
header("Content-type: text/html; charset=utf-8");
$con = mysql_connect("localhost","username","pass");
if (!$con)
{
die( Could not connect: . mysql_error());
}
mysql_select_db("php", $con);
//hmmmm ne dela
$sql="INSERT INTO Igralec (iID, iIME, iPRIIMEK, iSTAROST, iVELIKOST, iPOLOZAJ, ID)
VALUES ( $_POST[pid] , $_POST[pime] , $_POST[ppriimek] , $_POST[pstarost] , $_POST[pvelikost] , $_POST[ppolozaj] , $_POST[ppid] )";
if (!mysql_query($sql,$con))
{
die( Error: . mysql_error());
}
//die(print_r($_POST));
echo "Dodana je ena nova vrstica";
mysql_close($con);
?>
The problem is thath evry time i submit data, it writes false data into database all in format like 0--0-0-00 or simmilar to thath. But in array before is written it contains correct data but somehow it writes in database false data.