Jump to content

Recommended Posts

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
%>

Link to comment
https://forums.phpfreaks.com/topic/240660-never-learn-php-or-asp-before-need-help/
Share on other sites

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...

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.

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.

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?

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.

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

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.