Witam. Przeszukałem ogromną ilość for, w których był poruszany ten temat. Siedzę nad tym już dobre 5 godzin. Jestem początkujący.
Otóż mam formularz rejestracyjny, z którego dane chcę przenieść do tabeli w bazie MySQL. Tabela jest utworzona, a więc mam 3 pliki, oto ich zawartość:
connection.php
<?php
function connection() {
// host
$mysql_host = "localhost";
// user
$mysql_user = "*******";
// hasło
$mysql_pass = "**********";
// nazwa bazy
$mysql_db = "**************";
// nawiązujemy połączenie z serwerem MySQL
@mysql_connect($mysql_host, $mysql_user, $mysql_pass)
or die('Brak połączenia z serwerem MySQL.');
// łączymy się z bazą danych
@mysql_select_db($mysql_db)
or die('Błąd wyboru bazy danych.');
}
?>
Z bazą łączy się, tu nie ma problemu.
dodaj.php
<?php
require("connection.php");
connection();
$id = $_POST['ID'];
$nick = $_POST['Nick'];
$imie = $_POST['Imie'];
$nazwisko = $_POST['Nazwisko'];
$email = $_POST['Email'];
$haslo = $_POST['Haslo'];
$telefon = $_POST['Telefon'];
$zapytanie = "INSERT INTO `lista` VALUES ('".$id."',".$nick."','".$imie."','".$nazwisko."','".$email."','".$haslo."','".$telefon."')";
mysql_query($zapytanie);
?>
Oraz plik z formularzem:
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="pl" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8" />
<title>REJESTRACJA - *******.pl</title>
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style2.css" />
<link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
</head>
<body>
<div class="container">
<!-- Codrops top bar -->
<header>
<h1>Zarejestruj sie w serwisie **********.pl juz TERAZ!</span></h1>
<center><iframe width="420" height="315" src="//www.youtube.com/embed/**********" frameborder="0" allowfullscreen></iframe></center>
</header>
<section>
<div id="container_demo" >
<a class="hiddenanchor" id="toregister"></a>
<a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="rejestracja" class="animate form">
<form method="POST" action="dodaj.php">
<h1> REJESTRACJA </h1>
<p>
<label for="Nick" class="uname" data-icon="u">Nazwa użytkownika *</label>
<input name="Nick" required="required" type="text" placeholder="jestemzwyciezca007" />
</p>
<p>
<label for="Imie" class="imie" data-icon="u">Imię *</label>
<input name="Imie" required="required" type="text" placeholder="Jan" />
</p>
<p>
<label for="Nazwisko" class="nazwisko" data-icon="u">Nazwisko *</label>
<input name="Nazwisko" required="required" type="text" placeholder="Kowalski" />
</p>
<p>
<label for="Email" class="youmail" data-icon="e" > Twój e-mail *</label>
<input name="Email" required="required" type="email" placeholder="[email protected]"/>
</p>
<p>
<label for="Haslo" class="youpasswd" data-icon="p"> Twoje hasło *</label>
<input name="Haslo" required="required" type="password" placeholder="np. X8df!90EO"/>
</p>
<p>
<label for="Telefon" class="phone" data-icon="p"> Twój numer telefonu *</label>
<input name="Telefon" required="required" type="text" placeholder="np. 696 664 119"/>
</p>
<p class="signin button">
<input type="submit" value="Zarejestruj mnie"/>
</p>
<p class="change_link">
Masz już konto?
<a href="mm-login.php" class="to_register"> Zaloguj się! </a>
</p>
</form>
</div>
</div>
</div>
</section>
</div>
</body>
</html>
Czy ktoś byłby w stanie mi pomóc? Byłbym bardzo wdzięczny!
Konkretnie to nie ma żadnego błędu, wszystko wygląda na to, że dane zostały zapisane, aczkolwiek tabela nadal pusta.
dodanie znaczników <code class="php"> oraz <code class="html"> - fp