|
Posted by Luigi Donatello Asero on 07/25/05 17:46
"J.O. Aho" <user@example.net> skrev i meddelandet
news:3kj68dFulbe2U2@individual.net...
> Luigi Donatello Asero wrote:
> > "J.O. Aho" <user@example.net> skrev i meddelandet
> > news:3ki43oFue1jiU1@individual.net...
> >
> >>Luigi Donatello Asero wrote:
> >>
> >>>"J.O. Aho" <user@example.net> skrev i meddelandet
> >>>news:3khup2FufnknU2@individual.net...
> >
> >
> >
> >>The page seem to try to insert into the table at once without even
> >
> > spitting
> >
> >>out the two html-tags,
>
> Should have been splitting.
>
> > well, first I want to see a short simple form working and afterwards I
can
> > extend it, add meta tags and so on.
> > But I am not sure whether I understand what you mean by "spitting out
the
> > two html-tags".
> >
> >
> >
> >>You could break things up in two,one with the form only and the other
the
> >
> > php
> >
> >>that takes care of the data and saves things to the database.
> >>
> >
> > Do you mean to have 2 pages, one which displays the form before it has
been
> > filled in and another which gets the data from this form and send them
to
> > the database?
>
> Yes, less advanced and should give you less risk for problems.
> >
> >>You could change the "isset($_POST['add'])"
> >>to "array_key_exists('add', $_POST)"
> >
> >
> >
> >
> > Yes,
> > I have it there
> > "array_key_exists('add', $_POST)" && ($_POST['add']=="Skicka"))
>
> No, you don't see the other posts to see how the line should have looked
like.
>
>
>
> //Aho
Ok. Now I have seen it. I changed the code and got this one.
The page https://www.scaiecat-spa-gigi.com/sv/form.php shows a form but
when I enter data in the form the result is
"Error, insert query failed".
The question is what I missed this time.
<html>
<body>
<?PHP
if(array_key_exists('add', $_POST) && ($_POST['add']=="Skicka")) {
$fornamn = $_POST['fornamn'];
$efternamn = $_POST['efternamn'];
$db = mysql_connect("local host", "user", "password")
or die('I could not connect');
mysql_select_db("scaiecat_?", $db);
$query="INSERT INTO Formulr('frnamn','efternamn')
VALUES('$fornamn','$efternamn')";
mysql_query($query) or die('Error, insert query failed');
echo "Fljande har sparats till databasen:<br>\n
Frnamn: $fornamn<br>\n
Efternamn: $efternamn<br>\n";
} else {
?>
<form method="post">
<label for="Fornamn">Frnamn</label>
<input type="text" name="fornamn" id="Fornamn"><br>
<label for="Efternamn">Efternamn</label>
<input type="text" name="efternamn" id="efternamn"><br>
<input type=submit name="add" VALUE="Skicka">
</form>
<?PHP
}
?>
</body>
</html>
--
Luigi Donatello (un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/sv/sardinien-alghero-semesterbostad.php
Navigation:
[Reply to this message]
|