Hello i am having problems with my first php project which i am doing to teach my self a bit about it.So i made a form here is code:
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>
So here i require from user to enter all data to insert into database. Here is screenshoot of database:
and here is insert.php which is called as form action
<?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.