sir i have created an .asp script with the help of your site, i have gone through some forum posts and with some r&d i have accomplish the task howerver i need to do one more thing and i am unable to develop it myself. i tried some r&d but failed therefore i seek your help. please do help me
i have an contact us form in my website and i have created an asp script for it and it is working fine. now i need a little more from it.
i need that whenever any person fills the form to contact me his details get stored in an excel file placed in a folder in the website and the date get append in to it subsequently. i know it is possible but i dont how how to code it in the same asp script. my script is as under
--------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim strEmailMessage
Dim myMail
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIPAddress = "" Then
UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
End If
strFeedTitle = Request.Form("Title")
strFeedName = Request.Form("Name")
strFeedEmail = Request.Form("Email")
strFeedCell = Request.Form("Cell")
strFeedCompany = Request.Form("Company")
strFeedSubject = Request.Form("Subject")
strFeedMessage = Request.Form("Message")
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Msg. from Website "
myMail.From=strFeedEmail
myMail.To="info@addboss.in"
myMail.HtmlBody=strFeedMessage
myMail.Send
set myMail=nothing
strAutoReply="<html><body style='color:#333; font-family:Verdana; font-size:12px'><p>Dear<span style='font-weight:bold'> " & strFeedTitle & " " & strFeedName & "</span></p><p>Thanks for contacting us</p><p>Your mail has been submitted successfully and we will get back to you within three working days</p></p><br /><p>Regards</p><p>ADDBOSS <br> Corporate services consultants <br> www.addboss.in <br><br><br><br><br><hr><p style='color:#595959; font-size:10px;'><span style='font-weight:bold'>Note: </span>This is an auto response-back mail from the server of ADDBOSS for the acknowledgement of your submission. Please do not reply on this mail. However, if you need to contact us any further you may directly write to us on info@addboss.in</p></body></html>"
Set myMail2=CreateObject("CDO.Message")
myMail2.Subject="Auto-Reply from ADDBOSS"
myMail2.From="no-reply@addboss.in"
myMail2.To=strFeedEmail
myMail2.Htmlbody=strAutoReply
myMail2.Send
set myMail2=nothing
response.redirect("../thankyou.html")
%>
--------------------------------------------------------------
please help me.
if you need some more details please ask me and i will provide it here.
Storing in Excel file is not the best idea. The file has to be *LOCKED* for the entire duration of the update as you will have problems if 2 people ever tried to add at the same time.
Better would be an Access database.
Even better would be a MySQL or SQL Server database.
A possible alternative would be to add to the end of a ".CSV" file. Excel can open up ".CSV" files and they don't have as many problems as storing to Excel file would.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
so, could you please tell me the process of how apply access database to this system step by step. or if csv can be implemented without any hazel the how to apply that.
Just before the Response.Redirect line at the end, add this code:
Code:
CONST QT = """" ' creates a single quote mark
' put the items into the array in whatever order you prefer:
csvItems = Array( UserIPAddress, strFeedTitle, strFeedName, strFeedEmail, _
strFeedCell, strFeedCompany, strFeedSubject, strFeedMessage )
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set csv = FSO.OpenTextFile( Server.MapPath("emailLog.csv"), 8, True )
csv.WriteLine QT & Join( csvItems, QT & "," & QT ) & QT
csv.Close
Set FSO = Nothing
response.redirect("../thankyou.html")
%>
The only thing to watch out for is here:
Code:
Server.MapPath("emailLog.csv")
Aside from the fact that you can use any file name of your choice, though it should end in ".csv", that code as written probably won't work. That says "find the CSV text file in the same directory as this code." Almost surely the directory with the code will *NOT* be writable.
Typically, you will have a writable "data" directory that is either a subdirectory of the code directory or is "besided" the code subdirectory. So you will likely need something such as
Code:
Server.MapPath("data/emailLog.csv")
or
Server.MapPath("/data/emailLog.csv")
or
Server.MapPath("../data/emailLog.csv")
You will have to figure that part out based on the directory structure on your machine.
This code should write out a CSV file that looks like
Code:
"68.128.3.7","Amalgamated Widgets","Today's Widget Report","...", etc.
TWO CAUTIONS: In a ".csv" file like this, *NONE* of the field may contain *EITHER* quote marks or new line characters.
If you are unsure if they might, you could use a "cleaner" function something like:
Code:
Function clean( txt )
clean = Replace( Replace( Replace( txt, """","'" ), vbCR, " ", vbLF, " " )
End Function
So grateful to you,
i really owe you a lot, it was overwhelming.
the code worked so perfectly.
first off all i got afraid to implement this but than i slowly read all the lines and finally implement with the first step by copying the first block of code in my asp file and then uploaded the file to the server.
i than filled the form and checked the folder on the server, there was a file created with the name emaillog.csv. i then download the file and opened in excel and it got opened with all the details of the form. the first test got passed.
now i filled the form again and checked the folder, i simply refresh the folder in my fpt Clint (filezila) and i noticed that the size of the emaillog.csv has increased by a bit.
i download the file again and checked the values. i cant tell you my happiness, the purpose i have been looking for like hell is solved. the data is getting appended to the previous data. i mean now i will have this same file to collect all the data of the form filler.
this is so amazing, i mean just a few line of codes have done this work.
really a programmer can do anything.
i am so thankful to you. if you don't mind can i know you name and email id. or you can send me mail on rsingh21.jan13@gmail.com
sir as my problem is almost over, however there is one thing left, which is not an irk, but if something can be done for it then it will be so nice of you.
this block of coed is the email body which i receive in my email clinte.
all the details comes as it suppose to come, i only want a little change in the message area ie. strFeedMessage,
the message comes like a block of pragraph, i mean no tabs not line breaks, just a pragraph,
to explain this, for example if i fill the form and in the message area i write
"hi,
i have given my order,
plese chek to it
thanks"
now when i receive this mail, i simply get the above text as
"hi, may i have give my order, please check to it thanks."
although i can understand it but if it comes in a defined was as it was then it would be more better.
i tried to change the myMail.HtmlBody to myMail.TextBody then it change the results were so ugly that i cant tell here. the same block of html code was thrown like as it it.
first when i change the "strFeedMessage = Request.Form("Message")" to "strFeedMessage = Replace(Replace(Trim(Request.Form("Message"),vbCR,""),vbLF,"<br>")"
sir, with your help i have create a well to do script for my contact us form.
however there is one more thing i wanted to add in my form. that is the captcha. how do i add a captcha to my form so that any form submission pass through the anti spam guideline and does not goes into junk mails.
is there any script available for it or any asp code is required to create that. please help me to understand this functionality. i will be again great-full to you.
however one more thing i need to ask from you. with the current asp script i am able to send auto response and get the data append in the csv file. which i further pull with my excel to update the data.
i need to add one more variable in that array which gives the date and time stamp or may be two separate variables for date and time of the form submitter.
as a temporarily arrangement i have added an hidden input field with a java script code for the date and time, but the results are different at times, so i am planing to seek this help from you, that is to say let asp script does this trick for me. the only condition is that i need the current date & time of the senders system or the time should be Indian standard time in the format dd/mm/yyyy, 12:00:am/pm. please arrange this code for me. please refer my above asp script for the answer.