Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> dodawanie danych
-Wieviór-
post
Post #1





Goście







Czy może mi ktoś napisać prosty kod. Po prostu wpisuje jakieś dane do formularza na stronie, kilkam dodaj, i te dane są zachowywane jako rekordy w danej tabeli. Jestem początkujący w mySQL (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Wieviór-
post
Post #2





Goście







zrobiłem:
[php:1:111c9eefc3]<body>
<?
$dbhost = 'localhost';
$dbname = 'mateooo';
$dblogin = 'xxx';
$dbhaslo = 'xxx';
$connect = mysql_connect($dbhost, $dblogin, $dbhaslo) or die ("brak polaczenia");
mysql_select_db($dbname, $connect) or die("nie mozna wybrac bazy");
?>
<form action="" method="POST">
<input name="home"></input>
<input name="hgol"></input>
<input name="agol"></input>
<input name="away"></input>
<input type="submit" name="submit"></input>
</form>
<?
if($_POST['submit']){
$sql= "INSERT INTO mecze (id, home, hgol, agol, away) VALUES ('', '".$_POST['home']."', '".$_POST['hgol']."', '".$_POST['agol']."', '".$_POST['away']."')";
mysql_query($sql) or die("nie da rady");
}
?>
<?
mysql_close($connect);
?></body>[/php:1:111c9eefc3]

i nie działa (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 31.12.2025 - 11:50