print_r($_GET);
Array ( [nr
] => 2 [imie
] => adas
[nazwisko
] => ds
[send
] => Wyslij
)
Dodawanie rekordu do bazy:
<html>
<head>
<title>Dodaj Ucznia</title>
</head>
<body>
<?php
//ini_set('display_errors','Off');
if (isset($_GET['send']) && $_GET['send']=='Wyslij') {
/*if (!$_POST['email'] || !preg_match("/^[-0-9A-Z_\.]+@([-0-9A-Z_\.]+\.)+([0-9A-Z]){2,4}$/i", $_POST['email'])) {
echo "<font color='red'>Podany adres e-mail jest nieprawidłowy</font>";
($send=='Wyslij') {
*/
if(empty($_GET['imie'])){ echo "<font color='red'>Nie podałeś imienia!</font>"; // header("Refresh:0; url=dodaj.php");
}
else{
$zapytanie = "INSERT INTO oceny SET nr='".$_GET['nr']."', imie='".$_GET['imie']."', nazwisko='".$_GET['nazwisko']."";
echo "<BR><font color='green'><h2>Dane dodane prawidłowo !</h2></font> <br><h3><font color='orange'>Dziękujemy za wypełnieni formularza !</font></h3><br> <a href='index.php'> STRONA GŁÓWNA</a>"; header("Refresh:0; url=index.php");
}
}
else {
echo "<form method='get' action='dodaj.php'> <div align='center'>
<center>
<table border='1' width='50%' bordercolorlight='#000000' cellspacing='0' cellpadding='0'>
<tr>
<td width='50%'><font size='2' face='Verdana'>Numer</font></td>
<td width='50%' align='center'><font size='2' face='Verdana'><input type='text' name='nr' size='20'></font></td>
</tr>
<tr>
<td width='50%'><font size='2' face='Verdana'>Imie</font></td>
<td width='50%' align='center'><font size='2' face='Verdana'><input type='text' name='imie' size='20'></font></td>
</tr>
<tr>
<td width='50%'><font size='2' face='Verdana'>Nazwisko</font></td>
<td width='50%' align='center'><font size='2' face='Verdana'><input type='text' name='nazwisko' size='20'></font></td>
</tr>
<td width='100%' colspan='2'>
<p align='center'><font size='2' face='Verdana'><input type='submit' value='Wyslij' name='send'><input type='reset' value='Kasuj' name='B2'></font></td>
</tr>
</table>
</center>
</div>
</form>";
}
?>
</body>
</html>
Dałem warunek i wyskakuje "BŁĄD" czyli problem jest gdzieś tutaj:
else{
$zapytanie = "INSERT INTO oceny SET nr='".$_GET['nr']."', imie='".$_GET['imie']."', nazwisko='".$_GET['nazwisko']."";