Wednesday, August 18, 2010

How do i create a simple form using ASP?

i having problem creating a simple ASP form page. It will captured the data from the textbox(eg Name, Age) and once clicked on the submit button , it will send to one of the email.How do i create a simple form using ASP?
You need one HTML form to collect the data and send them to an ASP page, and the ASP page takes the data from the form and send them to an email.





**NOTE: I have trimmed the code from the source so that it becomes readable.








HTML form:





%26lt;form method=';POST'; action=';form_ac.asp'; name=';form1';%26gt;%26lt;br%26gt;


name:%26lt;input type=';text'; name=';name';%26gt;%26lt;br%26gt;


email:%26lt;input type=';text'; name=';email';%26gt;%26lt;br%26gt;


message:%26lt;br%26gt;%26lt;textarea name=';message'; cols=';40'; rows=';5';%26gt;%26lt;/textarea%26gt;%26lt;br%26gt;


%26lt;input type=';submit'; name=';Submit'; value=';Submit';%26gt;


%26lt;input type=';reset'; name=';Reset'; value=';Reset';%26gt;














ASP page:





%26lt;%@ Language=';VBscript'; %%26gt;


%26lt;% Option Explicit %%26gt;











%26lt;%





Dim name, email, message, NewMailObj


name=request.form(';name';)


email=request.form(';email';)


message=request.form(';message';)








Set NewMailObj=Server.CreateObject(';CDONTS.N鈥?br>

NewMailObj.From = ';michael@codefixer.com';


NewMailObj.To = ';whoever_you_want_to_send_it_to@hotmail.鈥?br>

NewMailObj.Subject = ';New message sent..';


NewMailObj.Body = ';the name you entered was '; %26amp; name %26amp; _


';%26lt;br%26gt;the email was '; %26amp; email %26amp; _


';%26lt;br%26gt;the message was '; %26amp; message





'you need to add the following lines FOR the mail to be sent in HTML format


NewMailObj.BodyFormat = 0


NewMailObj.MailFormat = 0


NewMailObj.Send





Set NewMailObj = nothing


Response.write ';The email was sent.';


%%26gt;How do i create a simple form using ASP?
Don't use ASP, use PHP it's much simpler and a better language.





You can use this PHP Form:


http://www.thedemosite.co.uk/phpformmail鈥?/a>

No comments:

Post a Comment