ragazzi vorrei fare un guestbook senza frame che però il messagio venga inviato nella stessa pagina che si trova il form x inviare i messaggi...
qualkuno mi può aiutare???
sono disperato...![]()
![]()
![]()
![]()
ragazzi vorrei fare un guestbook senza frame che però il messagio venga inviato nella stessa pagina che si trova il form x inviare i messaggi...
qualkuno mi può aiutare???
sono disperato...![]()
![]()
![]()
![]()
Se ho ben capito la cosa è abbastanza semplice.
La tua pagina è strutturata così?
form con i vari campi e sotto elenco dei messaggi lasciati dagli utenti giusto?
se mi dici i nomi dei campi del Database ti spiego come fare![]()
my pws: cafedelsol.it
il presente non ha estensione. è soltanto il continuo tradursi del futuro nel passato.
ok ecco gli script:
guestbook.asp
<html>
<head>
<title>Guestbook</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"
'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
'Loop through the recordset
Do While not rsGuestbook.EOF
'Write the HTML to display the current record in the recordset
Response.Write ("
")
Response.Write (rsGuestbook("Name"))
Response.Write ("
")
Response.Write (rsGuestbook("Comments"))
Response.Write ("
")
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
</body>
</html>
guestbook_form.htm
<html>
<head>
<title>Guestbook Form</title>
</head>
<body bgcolor="white" text="black">
<form name="form" method="post" action="add_to_guestbook.asp">
Name: <input type="text" name="name" maxlength="20">
Comments: <input type="text" name="comments" maxlength="60">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
add_to_guestbook.asp
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the tblComments table using the SQL query held in the strSQL varaiable
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("Name") = Request.Form("name")
rsAddComments.Fields("Comments") = Request.Form("comments")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
'Redirect to the guestbook.asp page
Response.Redirect "guestbook.asp"
%>
Vedo che hai già tutto pronto!
La cosa che devi fare è inserire il form di inserimento all'interno della pagina guestbook.asp (che è quella che visualizza i messaggi no?) con un semplice cut&past.
Il form andrà sempre a puntare sulla pagina add_to_guestbook.asp che, a sua volta, verrà indirizzata a guestbook.asp![]()
Non hai bisogno di fare grosse modifiche come vedi!![]()
my pws: cafedelsol.it
il presente non ha estensione. è soltanto il continuo tradursi del futuro nel passato.