Witam, mam taki oto problem z którym gryzę się od wczoraj:
Wpisuje dane do formularza, później owe dane wrzucam do mySQL, problem tylko w tym, że $pesel zawsze nadpisuje się jako "2147483647" pomimo, że nigdzie w kodzie czegoś takiego nie zadeklarowałem, przed samym zapisem do bazy dałem echo $pesel i wypisuje poprawny wprowadzony (w bazie mimo to nadal zapisuje 2147483647), czy mógłby ktoś poradzić mi dlaczego tak sie dzieje, jak to rozwiązać?
formularz:
<form name="f1" action="main.php?link=addchildren" method="POST" class="form-horizontal" role="form" style="padding-bottom:1em;"> <div class="formDiv form-group"> <label for="PESEL" class="col-sm-2">PESEL:
</label> <input id="check" type="text" for="PESEL" name="pesel" pattern="^[[0-9]{11}$" required /> <div class="formDiv form-group"> <label for="firstName" class="col-sm-2">Imie:
</label> <input type="text" name="firstName" pattern="^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ]{3,14}$" required /> <div class="formDiv form-group"> <label for="surName" class="col-sm-2">Nazwisko:
</label> <input type="text" name="surName" pattern="^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ]{3,14}$" required /> <div class="formDiv form-group"> <label for="birth" class="col-sm-2">Data urodzenia:
</label> <input type="text" name="birth" placeholder="dzien-miesiac-rok" pattern="^([1-2][0-9]|[3][0-1]|[0]?[1-9])-([0]?[1-9]|[1][0-2])-([1][9][8-9][0-9]|[2][0][0][0-9])$" required /> <div class="formDiv form-group" > <label for="momName" class="col-sm-2">Imię matki:
</label> <input type="text" name="momName" pattern="^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ ]{3,14}$" required /> <div class="formDiv form-group"> <label for="dadName" class="col-sm-2">Imię ojca:
</label> <input type="text" name="dadName" pattern="^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ]{3,14}$" required /> <div class="formDiv form-group"> <label for="place" class="col-sm-2">Miejscowość:
</label> <input type="text" name="place" pattern="^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ]{3,14}$" required /> <div class="formDiv form-group"> <label for="houseNr" class="col-sm-2">Numer domu:
</label> <input type="text" name="houseNr" pattern="^([0-9]{1,4}|[0]?[1-9])$" required /> <div class="formDiv form-group"> <label for="flatNr " class="col-sm-2">Numer mieszkania:
</label> <input type="text" name="flatNr" pattern="^[0-9]{1,4}$" required placeholder="W razie braku - 0" /> <div class="formDiv form-group"> <label for="POSTCode" class="col-sm-2">Kod pocztowy:
</label> <input type="text" name="POSTCode" placeholder="XX-XXX" pattern="^[0-9]{2}-[0-9]{3}$" required /> <div class="formDiv form-group"> <label for="phone" class="col-sm-2">Nr telefonu rodzica:
</label> <input type="tel" name="phone" required /> <div class="formDiv form-group"> <label for="email" class="col-sm-2">E-mail rodzica:
</label> <input type="email" name="email" placeholder="np. text@text.pl" required /> <div class="formDiv form-group"> <label for="password" class="col-sm-2">Specjalne Hasło:
</label> <!-- 123--> <input type="password" name="password" required /> <button id="sub" class="btn btn-primary" name = "submit">Zatwierdź
</button>
Łączenie z bazą
connectionSQL.php:
<?php
function connection(){
$host = "localhost";
$user = "root";
$pass = "haslo";
$db = "test";
function execute_query($query) {
if (!$r) {
echo "Cannot execute query: $query <br /> "; }
}
$connect=mysql_connect($host, $user, $pass) or
die("Could not connect to server"); //mysql_query("SET NAMES 'utf8'");
}
?>
Plik przetwarzania i zapisu danych:
functions_addchildren.php
function add(){
include 'includes/connectionSQL.php';
if (!isset($_SESSION['ID'])){ $_SESSION['ID']=2;} $dataClass=$_SESSION['ID'];
connection();
///$query = "DROP TABLE IF EXISTS Uczen";
//execute_query($query);
$sql = "CREATE DATABASE IF NOT EXISTS db";
mysql_query("CREATE TABLE Klasa_$dataClass(id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, pesel INT(11), Imie VARCHAR(15), Nazwisko VARCHAR(15), Klasa INT(1), Data_Urodzenia VARCHAR(8), Imie_Matki VARCHAR(15), Imie_Ojca VARCHAR(15), Miejscowosc VARCHAR(20), Numer_Domu INT(4), Numer_Mieszkania INT(2),
Kod_Pocztowy VARCHAR(6), Numer_Telefonu INT(20), Email TEXT(30)) ENGINE = InnoDB;");
}
$pesel = $_POST['pesel'];
$birth=$_POST['birth'];
$houseNr=$_POST['houseNr'];
$flatNr=$_POST['flatNr'];
$POSTCode=$_POST['POSTCode'];
$phone=$_POST['phone'];
$email=$_POST['email'];
mysql_query("INSERT INTO Klasa_$dataClass VALUES('', '$pesel','$firstName','$surName', '$dataClass','$birth','$momName', '$dadName', '$place', '$houseNr', '$flatNr','$POSTCode', '$phone', '$email')"); }