Dragoneze Posted June 28, 2011 Share Posted June 28, 2011 Hi all I had never learn php or asp before. I need help to translate an .asp script to php. Pls help, i had been reading thru tons of sites about php and asp scripts for hours but still not much ideas about what to do! My asp script is a form to email script that can send a submitted form to the webmaster and also the person that submit. Thanks.... Asp script: <% check = request.form("FormAction") if (check <> "" or check <> null) and check = "Submit" then Set Mail = Server.CreateObject("Persits.MailSender") $Mail.Host = "http://www.mywebsite.com"' Specify a valid SMTP server Mail.From = "mywebsite@mywebsite.com" ' Specify sender's address Mail.FromName = "mywebsite@mywebsite.com" ' Specify sender's name Mail.AddAddress request.form("email"), request.form("name") Mail.AddCC "yourwebsite@mywebsite.com", "Your Website" Mail.AddBCC "herwebsite@mywebsite.com", "Her Website" Mail.AddBCC "hiswebsite@mywebsite.com", "His Website" Mail.IsHTML = False Mail.Subject = "My email title - " & request.form("feedback") & " - Enquiry" Mail.Body = "Hi " & request.form("name") & "," & vbcrlf&_ vbcrlf&_ "Thank you for the details you have given us. We will be replying to you shortly." & vbcrlf&_ vbcrlf&_ "Name : " & request.form("name") & vbcrlf&_ "Company : " & request.form("company") & vbcrlf&_ "Designation : " & request.form("designation") & vbcrlf&_ "Email : " & request.form("email") & vbcrlf&_ "Contact nos. : " & request.form("contact") & vbcrlf&_ "4000pcs A5 Flyers at $230 : " & request.form("4000pcs A5 Flyers at $230") & vbcrlf&_ "1500pcs Vouchers + Voucher Design + Free Website at $250 : " & request.form("1500pcs Vouchers + Voucher Design + Free Website at $250") & vbcrlf&_ "Namecard printing at $8 each box : " & request.form("Namecard printing at $8 each box") & vbcrlf&_ "Design services : " & request.form("Design services") & vbcrlf&_ "Other printing services : " & request.form("Other printing services") & vbcrlf&_ vbcrlf&_ "Message " & vbcrlf&_ "----------------------------------------------------" & vbcrlf&_ request.form("message") & vbcrlf&_ vbcrlf&_ "Please do not reply to this automatically generated email." Mail.Send response.redirect "thankyou.html" end if %> Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/ Share on other sites More sharing options...
Maq Posted June 28, 2011 Share Posted June 28, 2011 In the future, please place OR tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236052 Share on other sites More sharing options...
Maq Posted June 28, 2011 Share Posted June 28, 2011 1) If you don't know any of these languages, then why are you taking on this task? 2) No one is going to do this for you and you showed NO attempt. My asp script is a form to email script that can send a submitted form to the webmaster and also the person that submit. There are plenty of PHP examples on Google, look them up... Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236059 Share on other sites More sharing options...
Dragoneze Posted June 28, 2011 Author Share Posted June 28, 2011 I have used this asp on one of my website but now i need it on php for another site. I have a few various php examples but none can send an email back to the person that submit the form. I thought i can seek help and probably advices. Getting into forum was my last resort after searching on net for the last 5 hrs... The thing is i just dont understand how to convert this asp to php without errors.... i have another php form to email and it works fine but i will need to have the code for sending back to the person that submit, with the email content about what he/she have chosen. Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236067 Share on other sites More sharing options...
KevinM1 Posted June 28, 2011 Share Posted June 28, 2011 There's no perfect 1-to-1 conversion from ASP to PHP. You say you already have a PHP form which can send emails. Why can't you simply modify that form to fit your needs? That's an easier way to approach the problem than trying to convert languages. Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236070 Share on other sites More sharing options...
Dragoneze Posted June 29, 2011 Author Share Posted June 29, 2011 There's no perfect 1-to-1 conversion from ASP to PHP. You say you already have a PHP form which can send emails. Why can't you simply modify that form to fit your needs? That's an easier way to approach the problem than trying to convert languages. Hi, thanks for replying. My webhost is linux platform therefore the asp cant worked. I already amended the asp script and added variables i needed but when i placed it in my host, it din worked. Then i read online that asp cannot work on linux. This asp script i used in another host which is window shared server and it works perfectly fine. And this form works well without spam emails. Any advice? Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236132 Share on other sites More sharing options...
vbconz Posted June 29, 2011 Share Posted June 29, 2011 There's no perfect 1-to-1 conversion from ASP to PHP. You say you already have a PHP form which can send emails. Why can't you simply modify that form to fit your needs? That's an easier way to approach the problem than trying to convert languages. Hi, thanks for replying. My webhost is linux platform therefore the asp cant worked. I already amended the asp script and added variables i needed but when i placed it in my host, it din worked. Then i read online that asp cannot work on linux. This asp script i used in another host which is window shared server and it works perfectly fine. And this form works well without spam emails. Any advice? Some facts you need to know: ASP - runs on an IIS server (e.g. microsoft server) PHP - runs whereever a php server is set up - normally linux ASP will not run on a linux server* PHP will not run on an IIS server* Both ASP and PHP run ON THE SERVER so - Whatever the form looks like that is presented to the customer via your asp form will need to capture the customers email address, return it as part of a post , get captured by the php server, used to create an email on the SERVER SIDE and then send an email from there. You will need two pages at least. Page 1 - showForm - Present the form to the client and get them to fill in info and push a submit button. Page 2 - Get details from the forms return run whatever logic you want run against it and also create an email and get the server to send it out. if you do not understand server side processing, posts, what languages run on what servers etc then you need to engage a web developer to sort this out for you Shane * Unless a special add in or thrid party app has been installed and configured etc etc etc. Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236136 Share on other sites More sharing options...
vbconz Posted June 29, 2011 Share Posted June 29, 2011 Hi all I had never learn php or asp before. I need help to translate an .asp script to php. Pls help, i had been reading thru tons of sites about php and asp scripts for hours but still not much ideas about what to do! My asp script is a form to email script that can send a submitted form to the webmaster and also the person that submit. Thanks.... Asp script: <% check = request.form("FormAction") if (check <> "" or check <> null) and check = "Submit" then Set Mail = Server.CreateObject("Persits.MailSender") $Mail.Host = "http://www.mywebsite.com"' Specify a valid SMTP server Mail.From = "mywebsite@mywebsite.com" ' Specify sender's address Mail.FromName = "mywebsite@mywebsite.com" ' Specify sender's name Mail.AddAddress request.form("email"), request.form("name") Mail.AddCC "yourwebsite@mywebsite.com", "Your Website" Mail.AddBCC "herwebsite@mywebsite.com", "Her Website" Mail.AddBCC "hiswebsite@mywebsite.com", "His Website" Mail.IsHTML = False Mail.Subject = "My email title - " & request.form("feedback") & " - Enquiry" Mail.Body = "Hi " & request.form("name") & "," & vbcrlf&_ vbcrlf&_ "Thank you for the details you have given us. We will be replying to you shortly." & vbcrlf&_ vbcrlf&_ "Name : " & request.form("name") & vbcrlf&_ "Company : " & request.form("company") & vbcrlf&_ "Designation : " & request.form("designation") & vbcrlf&_ "Email : " & request.form("email") & vbcrlf&_ "Contact nos. : " & request.form("contact") & vbcrlf&_ "4000pcs A5 Flyers at $230 : " & request.form("4000pcs A5 Flyers at $230") & vbcrlf&_ "1500pcs Vouchers + Voucher Design + Free Website at $250 : " & request.form("1500pcs Vouchers + Voucher Design + Free Website at $250") & vbcrlf&_ "Namecard printing at $8 each box : " & request.form("Namecard printing at $8 each box") & vbcrlf&_ "Design services : " & request.form("Design services") & vbcrlf&_ "Other printing services : " & request.form("Other printing services") & vbcrlf&_ vbcrlf&_ "Message " & vbcrlf&_ "----------------------------------------------------" & vbcrlf&_ request.form("message") & vbcrlf&_ vbcrlf&_ "Please do not reply to this automatically generated email." Mail.Send response.redirect "thankyou.html" end if %> FYI - the above ASP is also badly written. field names containing '$' spaces, plus symbols etc are being sent through as posted data. Even if you convert to php you will either: a) have to escape a lof of characters in field names b) Have the fields fail to be recognised as they probably contain illeagal chars in field names c) run a huge risk of somebody hacking things as you will be allowing really dodgy chars through as field names. e.g. field name: '500pcs Vouchers + Voucher Design + Free Website at $250', field name: "4000pcs A5 Flyers at $230" you need to ditch the $, spaces and plus symbols out of the field names which means your html file needs to be re-written as well. Also if (check <> "" or check <> null) and check = "Submit" then The bracketed checks are redundent as if Check="submit" then check <> "" is always true and check<>null is always true. If you are worried about a null return causing an error, then use if isNull(check) then 'do something as no submit sent elseif check="Submit" then 'do stuff ehre else 'throw an error and clean up here as check <> 'Submit' end if Quote Link to comment https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/#findComment-1236147 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.