Storing an ASP page

Discussion in 'Web Design & Coding' started by Nismo83, Oct 26, 2002.

  1. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    Help all professional programmer out here..

    I need some help regarding on storing a ASP page in the database so that the user(receiver) can access it such as greeting cards with the message key in by the sender.

    I hope u guys understand what i'm blabbing 'bout :D
     
  2. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Well you don't store the page. You just store the string with the message in it and assign it a unique ID number. Then the receiver opens a page with the ID number as a parameter and the page sidplas the appropriate string.
     
  3. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    well.. thanks Zedric. I get the picture on how it works. But how do i store the message in a string? Any tutorial or some kind of example which explain in more detail? :D

    Sorry to trouble you
     
  4. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    I'm not so good at ASP but since it's similar to PHP I guess it would work like this:
    Make a form with a textarea (for the message). Call it "message". Submit the form using POST to another page (or the same, your choise). The message will now be available in the ASP code (in PHP is directly in the variable "message"). Then you store it in the DB.
     
  5. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    I dun get what u mean by The message will now be available in the ASP code (in PHP is directly in the variable "message").
     
  6. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    OK. I the new page (the page you sibmitted the form data to) you will now have a variable called "message" that contains the message the user typed in on the previous case. This is how it is in PHP. It may be different in ASP but that can easily be found out if you look at examples (there are millions on the web).
     
  7. Informant

    Informant Guest

    This assumes you are using a access database which is very common for what you are requesting.
    <%
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "ConnectionStringHereLookForExamplesOnTheWeb"
    set rs = conn.execute("Select * from tableNameHere where ColumnID = IDHERE")
    %>

    <!-- Apply your Html Formatting here -->

    <%=rs("Message")%>

    <%

    conn.Close
    Set rs = nothing
    set conn = Nothing
    %>

    Now if you make a access database with 2 fields in it one called ColumnID wich will be your primary key and unique ID and one called Message that will probably be a field type "Memo" and use the little script I just wrote above you will be able to pull that info based on ID at will........
     
  8. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    thanks a lot for the info..

    I am currently { [​IMG] | | [​IMG] | | [​IMG] }
    =========================
    Intel P4 1.5 Ghz
    Intel D850GB MOBO
    256MB PC 800 RDRAM
    20GB Maxtor HDD (5400 RPM)
    40GB Maxtor HDD (7200 RPM)
    52X Creative CDROM
    8X4X32 Creative CDRW
    16X ASUS DVD ROM
    Iomega 100 MB USB Zip Drive
    SYBA Ultra ATA IDE controller card
    SB live 5.1 DE
    Aging Gainward 64MB GF2MX400 --> | Upgrading to GF4 Ti4 series |
    Altec Lansing ACS 56
    Dlink D538TX NIC

    =========================
     
  9. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    Code:
    <%
    	' connect to the MS Access database in the same directory
    	strDbPath = Server.MapPath(".") & "\users.mdb"
    	strconn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("users.mdb")
    
    	Set rs = Server.CreateObject("adodb.recordset")
    	rs.Open "users", strconn, 2, 3
    
    	If Request("Send") <> "" Then
                Set Mail = Server.CreateObject "XXX.mailserver")
    		Mail.Host = strHost
    		
    		Mail.From = "XXX@abc.com"
    		Mail.FromName = "Request("From")
    		Mail.Subject = Request("Subject")
    		Mail.Body = Request("Body")
    
    		Mail.Send  ' finally send message
    
    
    after storing the message, how do i incorporate it as a link to the mail that i wanted to send it out? For example is: http://www.abc.com?cards=1...

    :confused:
     
  10. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    Code:
    <%
    	' connect to the MS Access database in the same directory
    	strDbPath = Server.MapPath(".") & "\users.mdb"
    	strconn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("users.mdb")
    
    	Set rs = Server.CreateObject("adodb.recordset")
    	rs.Open "users", strconn, 2, 3
    
    	If Request("Send") <> "" Then
                Set Mail = Server.CreateObject "XXX.mailserver")
    		Mail.Host = strHost
    		
    		Mail.From = "XXX@abc.com"
    		Mail.FromName = "Request("From")
    		Mail.Subject = Request("Subject")
    		Mail.Body = Request("Body")
    
    		Mail.Send  ' finally send message
    
    
    after storing the message, how do i incorporate it as a link to the mail that i wanted to send it out? For example is: http://www.abc.com?cards=1...

    BTW, i've done an normal mail appz and when i tried to send it, it says Error occurred: 550 5.7.1 Unable to relay for xxx@abc.com i'm using PostCast Server
    :confused:
     
  11. Informant

    Informant Guest

    You need a valid smtp server.
     
  12. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    What you do is you store the entire mail in a variable (say mailBody). Something like this:
    Code:
    mailBody = "Hi!\nBla bla bla, yada yada. Click below to bla bla:\n\n [url]http://www.abc.com/?cards=[/url]" &
    cardID & "\n\nBla bla, yada yada.\n\nRegards\nWhoever."
    Sort of anyway. ;)
    Then you send it off (provided you get the SMTP to work).
     
  13. Nismo83

    Nismo83 OSNN AZN Addict

    Messages:
    383
    Code:
    <%
    dim strID 
    strID=Request("cardid")
    Set con=Server.CreateObject("ADODB.Connection")
    Set RecordSet=Server.CreateObject("ADODB.RecordSet")
    
    strconn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("data.mdb")
    con.Open strconn 
    
    sql =  "SELECT * FROM birthday WHERE cardid = strid "
    
    set RecordSet = con.execute(sql)
    
    
    Response.write RecordSet("image")
    %>
    
    When this page load it kept load the first image only.. i want it to load based on the querystring that i have select from the previous page. How do i do it?

    Eg. http://www.abc.com?id=1 -> display this image
    http://www.abc.com?id=2 -> display that image
     
  14. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Does it know to replace strid but not cardid in the SQL string?

    I'd do:
    sql = "SELECT * FROM birthday WHERE cardid = " & strid
     
  15. Informant

    Informant Guest

    My Typo Zedric is right....