Archive for the ‘ASP’ Category

Godaddy ASP Form Mailer with Upload

Thursday, September 18th, 2008

 This is merely an expansion on this blog post: http://www.asp101.com/articles/jacob/scriptupload.asp

You will need to download the asp script from there for this to work. You’ll also need to specify a writable directory named uploads.

The script below is for anyone using godaddy and cannot get gdform.asp to send you an email AND upload a file. It emails you a link to the file after it uploads along with form fields.

  1.  
  2. <!—#include file="fileuploaderupload.asp"—>
  3. <%  
  4.  
  5. Dim landing_page, host_url
  6. Dim fso, outfile, filename, dirname, myFolder
  7. Dim req_method, key, value
  8. Dim bErr, errStr, bEmpty
  9. Dim File
  10. On Error resume next
  11. bErr = false
  12. bEmpty = true
  13. errStr = ""
  14. Set fso = Server.CreateObject("Scripting.FileSystemObject")
  15. host_url = Request.ServerVariables("HTTP_HOST")
  16. req_method = Request.ServerVariables("REQUEST_METHOD")
  17. dtNow = Now()
  18. filename = Server.MapPath("ssfm")
  19. uppath = Server.MapPath("uploads")
  20. dirname = filename
  21. filename = filename &amp; "gdform_" &amp; DatePart("M", dtNow) &amp; DatePart("D", dtNow) &amp; DatePart("YYYY", dtNow) &amp; DatePart("N", dtNow) &amp; DatePart("S", dtNow)  
  22.  
  23. Dim MyUploader
  24. Set MyUploader = New FileUploader
  25. MyUploader()  
  26.  
  27. For Each File In MyUploader.Files.Items
  28. File.SaveToDisk uppath  
  29.  
  30. Set outfile = fso.CreateTextFile(filename, true, false)  
  31.  
  32. outfile.WriteLine("<GDFORM_VARIABLE NAME=name START>" &amp; vbCRLF)
  33. outfile.WriteLine(MyUploader.form("name") &amp; vbCRLF)
  34. outfile.WriteLine("<GDFORM_VARIABLE NAME=name END>")  
  35.  
  36. outfile.WriteLine("<GDFORM_VARIABLE NAME=companyname START>" &amp; vbCRLF)
  37. outfile.WriteLine(MyUploader.form("companyname") &amp; vbCRLF)
  38. outfile.WriteLine("<GDFORM_VARIABLE NAME=companyname END>")  
  39.  
  40. outfile.WriteLine("<GDFORM_VARIABLE NAME=email START>" &amp; vbCRLF)
  41. outfile.WriteLine(MyUploader.form("email") &amp; vbCRLF)
  42. outfile.WriteLine("<GDFORM_VARIABLE NAME=email END>")  
  43.  
  44. outfile.WriteLine("<GDFORM_VARIABLE NAME=phone START>" &amp; vbCRLF)
  45. outfile.WriteLine(MyUploader.form("phone") &amp; vbCRLF)
  46. outfile.WriteLine("<GDFORM_VARIABLE NAME=phone END>")  
  47.  
  48. outfile.WriteLine("<GDFORM_VARIABLE NAME=projectinfo START>" &amp; vbCRLF)
  49. outfile.WriteLine(MyUploader.form("projectinfo") &amp; vbCRLF)
  50. outfile.WriteLine("<GDFORM_VARIABLE NAME=projectinfo END>")  
  51.  
  52. outfile.WriteLine("<GDFORM_VARIABLE NAME=linktofile START>" &amp; vbCRLF)
  53. outfile.WriteLine("http://www.ha-printing.com/uploads/" &amp; File.FileName &amp; vbCRLF)
  54. outfile.WriteLine("<GDFORM_VARIABLE NAME=linktofile END>")
  55. Next
  56. landing_page = "thank_you.html"
  57. outfile.close
  58. response.Redirect "http://" &amp; host_url &amp; "/" &amp; landing_page
  59. set fso = nothing  
  60.  
  61. %>

Leading zeros - the easy way

Thursday, September 20th, 2007

Most web developers will say you have to do all these IF statements and what-not just to get a zero in front of a number. Example, I want an 8 digit date (mmddyyyy). ASP will only generate a single digit “1″ for January and a single digit “1″ for the first. This means I end up with 112007. Not good. Here’s a sample to solve this problem :

<%
str= “1″
str=right(”00″ & str, 2) // returns “01″

%>

Perfect! What this is doing is adding 00 to str, so it then becomes “001″, then it takes the two right-most characters. Returning “01″. This is good because if you have a two digit day or month, then the two right-most characters are the two digits of that day or month. Bam! Easy huh?

Reset a result source in PHP with mysql_data_seek

Tuesday, August 28th, 2007
  1. $result = mysql_query("SELECT names FROM table;");          
  2.  
  3. while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
  4.  
  5.           //procedure
  6. }
  7.  
  8. mysql_data_seek($result,0); // Reuse your recordset
  9.  
  10. while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
  11.  
  12.         //procedure
  13.  
  14. }
watch free movies online download movies online free movies online