Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Commenti Alle News

  1. #1

    Commenti Alle News

    Ciao a tutti ragazzi, sto realizzando il mio sito in asp con db mysql.
    Vorrei mettere i commenti alle varie news.
    ho due tabelle
    tabella1
    News (ID, argomento,titolo,testo,...)
    commenti (id, id_news, nome_cognome, indirizzoemail,commento)

    ho creato il file scrivicommento.asp che sarebbe il form
    ed il file scrivicommento2.asp che servirebbe per eseguire il tutto...

    Come faccio ad assegnare nel campo id_news della tabella commenti uguale a ID della tabella News?
    Grazie mille dell'attenzione e ciaoooo
    se avete link ad articoli/script va bene ugualmente.

    CIAOOO
    Francesco
    http://www.cubamylove.com
    http://www.casadamarys.com
    Cuba Trinidad

  2. #2
    semplicemente mandi in querystring l 'id della news, lo metti come campo nascosto nel form e poi lo vendemmi nel secondo file con request.form
    E' come ho fatto io per le mie news.

    X esempio
    Dalla pagina news.asp metti il link inserici commento con link
    scrivicommento.asp?id_news=<%=rs("id")%> (in caso rs sia il tuo recodset)

    poi in scrivicommento.asp
    id_news = Request.Querystring("id_news")

    crei un campo hidden con valore id_news

    in scrivicommento2.asp
    id_news= request.Form("id_news")


  3. #3
    Grazie mille per il prezioso aiuto... ci sono quasi!!!!
    mi sono dimenticato un passaggio...
    io in news.asp non ho il link "inserisci commento", ma cliccando sul titolo della news mi rimanda nella pagina dove leggo per esteso la mia news.
    Quest'ultima pagina si chiama... ovviamente leggi_news.asp che mi fa leggere l'articolo per esteso.
    Alla fine dell'articolo c'è questo benedetto link scrivicommento.asp (forum)
    Francesco
    http://www.cubamylove.com
    http://www.casadamarys.com
    Cuba Trinidad

  4. #4
    ho provato a fare quello che hai detto... al posto del file news.asp c'era il file leggi_news.asp
    ma non funziona, mi da questo errore ...
    chiaramente ho fatto qualche cosa che non va...


    Microsoft VBScript runtime error '800a000d'

    Type mismatch: 'frmid_news'

    /scrivicommento2.asp, line 27

    come posso fare?

    Grazie mille e scusa del disturbo.

    CIAOOO
    Francesco
    http://www.cubamylove.com
    http://www.casadamarys.com
    Cuba Trinidad

  5. #5
    l'errore sta in scrivicommento2.asp.. se non posti il codice non posso sapere cosa ci stà scritto!

  6. #6
    effettivamente hai ragione...
    te li copio tutti e tre i file in questione...



    leggi_news.asp (file che visualizza la news per intero e contiene il link a scrivicommento.asp
    <html>
    <head>
    <title>******************</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"#FFFFFF" text="#000000">
    <link rel="stylesheet" href="styles.css" type"text/css">

    <style type="text/css">
    <!--
    .style6 {color: #E7DF94}
    -->
    </style>



    <% Sub MostraPagina() %>


    <%
    ID=Request("ID")
    If not ISNumeric(ID) or Len(ID) = 0 Then
    ID = 1
    End if
    if ID = 0 Then
    ID = 1
    End IF


    dim intVolta
    intVolta="0"

    Set Conn=Server.CreateObject("ADODB.Connection")
    dbConn="server=00.000.000.00;db=******;driver={MyS QL ODBC 3.51 Driver};uid=*************;pwd=********;option=3;"
    Conn.Open dbConn
    sql="SELECT * FROM News WHERE ID = "&ID&" order by id DESC "
    set rs=Server.CreateObject("ADODB.Recordset")
    rs.open sql,Conn,3,3

    do while not(rs.eof)
    if intVolta="1" then
    intVolta="0"
    intTesto="#00FF99"
    intSfondo="#FFFF00"
    else
    intVolta="1"
    intTesto="#FFFF99"
    intSfondo="#33CCFF"
    end if
    %>


    </p>
    <center>
    <table width="687" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFCE">
    <tr>
    <td width="50" height="18" background="img_tema/barraalto_sx.jpg" bgcolor="#FFFDCA"><div align="left"></div></td>
    <td width="139" bgcolor="#FFFDCA"><div class="style1"><%=rs("argomento")%></div></td>
    <td width="373" bgcolor="#FFFDCA"><span class="style5"><%=rs("titolo")%></span></td>
    <td width="126" background="img_tema/barraalto_dx.jpg" bgcolor="#FFFFFF"></td>
    </tr>
    <tr bordercolor="#000000" background="img_tema/barracentrale.jpg">
    <td colspan="4"><p class="style3"></p>
    <table width="688" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="40"></td>
    <td colspan="2" class="feature">
    [img]<%=rs([/img]">
    <%=rs("introduzione")%>


    <%=rs("news")%></p></td>
    <td width="80"></td>
    </tr>
    <tr>
    <td></td>
    <td width="272"><div align="center">">scrivi commento</div></td>
    <td width="296"> leggi commento </td>
    <td></td>
    </tr>
    </table>
    <p class="style3"></p></td>
    </tr>
    <tr>
    <td colspan="4" class="style4a"><div align="right"><div class="style4"> Scritto il <%=rs("data")%> alle ore <%=rs("ora")%></div></div></td>
    </tr>
    </table>

    <%
    rs.movenext
    loop
    rs.close
    set rs=Nothing
    Conn.close
    set Conn=Nothing
    %>

    </TABLE>
    </center>

    <% End Sub %>

    </body>

    scrivicommento.asp (form per inserimento dati)
    <body>
    <form name="inserimento commenti" method="post" action="scrivicommento2.asp">



    <input name="id_news" type="text" value="<% id_news=Request.Querystring("id_news")%>" size="30" maxlength="30">
    </p>


    Nome e Cognome
    <input name="nome_cognome" type="text" value="<%=nome_cognome%>" size="30" maxlength="30">
    </p>


    Indirizzo e-mail valido:
    <input name="indirizzoemail" type="text" value="<%=indirizzoemail%>" size="30" maxlength="30">
    </p>


    Commento:
    <textarea name="commento" cols="50" rows="3"></textarea>



    <input type="submit" name="invio" value="INVIO DATI"></P>

    </form>
    </body>
    </html>

    scrivicommento2.asp
    <%
    Function scrivicommenti(id_news,nome_cognome,indirizzoemail ,commento)
    Set Conn=Server.CreateObject("ADODB.Connection")
    dbConn="server=00.000.000.00;db=******;driver={MyS QL ODBC 3.51 Driver};uid=**********;pwd=********;option=3;"
    Conn.Open dbConn
    sql="SELECT * FROM commenti"
    set rs=Server.CreateObject("ADODB.Recordset")
    rs.open sql,Conn,3,3

    rs.addnew()
    rs("id_news")=id_news
    rs("nome_cognome")=nome_cognome
    rs("indirizzoemail")=indirizzoemail
    rs("commento")=commento
    rs.update

    rs.close
    set rs=Nothing
    Conn.close
    set Conn=Nothing
    End Function
    %>
    <%
    'Script
    frmid_news("id_news")
    frmnome_cognome.Form("nome_cognome")
    frmindirizzoemail=request.Form("indirizzoemail")
    frmcommento=replace(request.Form("commento"),chr(1 3),"
    ")

    call scrivicommenti(id_news,frmnome_cognome,frmindirizz oemail,frmcommento)
    'if err<>0 then
    ' response.Write("Errore n." & err & "! Descrizione: " & err.description )
    'end if
    response.redirect "homepage.asp"
    %>


    grazie ancora tantissimo
    ciao e buon week-end.

    Francesco
    http://www.cubamylove.com
    http://www.casadamarys.com
    Cuba Trinidad

  7. #7
    il problema stà nel fatto che la variabile id_news devi processarla anche nel file scrivicommento.asp
    Come ti ho postato in precedenza ti ripeto
    nel file scivicommento.asp
    codice:
    id_news = Request.Querystring("id_news")
    e richiami la querystring che invii dal link

    poi nel form metti il campo hidden
    codice:
    <input type="hidden" name="id_news" value="<%=id_news%>">
    che poi processi in scrivicommento2.asp
    codice:
    frmid_news.Form("id_news")
    non conosco questa sintassi ma te la prendo per buona. Io uso il request.form
    Ciao e buon lavoro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.