Hej... Jeg har prøvet at få en html formular's data indsat i en
Access database via. HTML.dk's tutorial, men når jeg har udfyldt
alle felterne i formularen og trykker "Send" kommer den med en
Internal Server Error (fejl id: 500). Selvom at det hele er efter
guiden!!
Her er min formular: (opret.htm)
<html>
<head>
<title>Opret Brugernavn</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkPw(form) {
pw1 = form.pass.value;
pw2 = form.repass.value;
if (pw1 != pw2) {
alert ("\nDine 2 password's matchede IKKE hinanden!!!")
return false;
}
else return true;
}
// End -->
</script>
</head>
<body>
<form name="brugernavn" action="index.asp" method="post"
onSubmit="return checkPw(this)">
<p align="center"><font size="6">Opret Brugernavn: </font></p>
<div align="center">
<center>
<table border="1" width="320" height="496">
<tr>
<td width="413" height="50" align="center">Navn:</td>
<td width="335" height="50" align="center"><input
type="text" name="navn" size="20"></td>
</tr>
<tr>
<td width="413" height="50" align="center">Adresse:</td>
<td width="335" height="50" align="center"><input
type="text" name="adresse" size="20"></td>
</tr>
<tr>
<td width="413" height="50" align="center">Post nummer:
</td>
<td width="335" height="50" align="center"><input
type="text" name="postnr" size="20" maxlength="4"></td>
</tr>
<tr>
<td width="413" height="50" align="center">By: </td>
<td width="335" height="50" align="center"><input
type="text" name="by" size="20"></td>
</tr>
<tr>
<td width="413" height="50" align="center">Telefon
Nummer: </td>
<td width="335" height="50" align="center"><input
type="text" name="tlf" size="20" maxlength="8"></td>
</tr>
<tr>
<td width="413" height="50" align="center">Mobil Nummer:
</td>
<td width="335" height="50" align="center"><input
type="text" name="mobil" size="20" maxlength="8"></td>
</tr>
<tr>
<td width="413" height="50" align="center">E-Mail: </td>
<td width="335" height="50" align="center"><input
type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="413" height="50" align="center">Brugernavn:
</td>
<td width="335" height="50" align="center"><input
type="text" name="user" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="413" height="50" align="center">Password:
</td>
<td width="335" height="50" align="center"><input
type="password" name="pass" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="413" height="46" align="center">Gentag
Password :</td>
<td width="335" height="46" align="center"><input
type="password" name="repass" size="20" maxlength="15"></td>
</tr>
<tr>
<td width="413" height="50" align="center"><input
type="submit" value="Send" name="submit"></td>
<td width="335" height="50" align="center"><input
type="reset" value="Nulstil" name="reset"></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
Og her er index.asp:
<body>
<%
' Databaseforbindelse - husk at angive sti til din database
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("/database.mdb")
Conn.Open DSN
' SQL sætning opbygges
strSQL = "Update personer set "
strSQL = strSQL & "navn= '" & Request.Form(brugernavn) & "'"
strSQL = strSQL & "adresse= '" & Request.Form(brugernavn) & "'"
strSQL = strSQL & "postnummer= '" & Request.Form(brugernavn) &
"'"
strSQL = strSQL & "by= '" & Request.Form(brugernavn) & "'"
strSQL = strSQL & "tlf= '" & Request.Form(brugernavn) & "'"
strSQL = strSQL & "mobil= '" & Request.Form(brugernavn) & "'"
strSQL = strSQL & "user= '" & Request.Form(brugernavn) & "'"
strSQL = strSQL & "password= '" & Request.Form(brugernavn) & "'"
' SQL sætning eksekveres
Conn.Execute(strSQL)
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
%>%>
<h1>Databasen er opdateret!</h1>
</body>
Det hele er i orden i databasen,...
Tabeller:
id (auto)
navn (tekst)
adresse (tekst)
postnummer (tal)
by (tekst)
tlf (tal)
mobil (tal)
email (tekst)
user (tekst)
password (tekst)
Håber i kan hjælpe...
MVH Lars Rasmussen
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials