annyvz 0 Posted August 4, 2014 Report Share Posted August 4, 2014 Hi there, I am VERY new to asp and need help please! I have a form with a submit button, but I need the form to automatically submit to a mail address my code: <form class="pure-form pure-form-stacked" method="POST" action="tizagEmail.asp"> <fieldset> <legend><strong>Personal Information</strong></legend><br> <div class="pure-g"> <div class="formstyle"> <label for="first-name">First Name</label> <input id="first-name" type="text"> </div> <div class="formstyle"> <label for="last-name">Last Name</label> <input id="last-name" type="text"> </div> <div class="formstyle"> <label for="email">E-Mail</label> <input id="email" type="email" required> </div> <div class="formstyle"> <label for="state">Exam Level</label> <select id="state" class="pure-input-1-2"> <option>Level 1</option> <option>Level 2</option> <option>Level 3</option> </select> </div> </div> <br><form class="formstyle"><script>DateInput('orderdate', true, 'DD-MON-YYYY')</script></form><br><input type="submit" value="Submit"></form> --------------------------------------------------------------------------------------------------------------------------------------- My asp code: <%'Sends an emailDim mailSet mail = Server.CreateObject("CDO.Message")mail.To = Request.Form("To:annalin@ctrack.co.za")mail.From = Request.Form("From:issuetr@digicore.co.za")mail.Subject = Request.Form("Subject:Exam Registration")mail.TextBody = Request.Form("Body")mail.Send()Response.Write("Mail Sent!")'Destroy the mail object!Set mail = nothing%> Please help me where my mistake is lying that this form wont automatically submit Thank you! Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 4, 2014 Report Share Posted August 4, 2014 What happens when you submit the form? Are there any error messages?You have a form inside the form. A form cannot contain another form, remove the inner form.You're not using request.form correctly. You should change your inputs to use names:<input type="text" name="user_email_address">Then you get those values from request.form using the input name:Request.Form("user_email_address")If you're using a hard-coded value then you don't need Request.Form.mail.Subject = "Exam Registration" Quote Link to post Share on other sites
annyvz 0 Posted August 5, 2014 Author Report Share Posted August 5, 2014 Hi, Thank you so much for your response! I have removed the extra form tags.. I have a couple of questions: 1. Does the <input type="text" name="user_email_address"> go into my html file, and the Request.Form("user_email_address") into my seperate .asp file? 2. How do I code the input on the parts of the form, like the calendar and dropdown list, to obtain those values to go into the mail that is automatically sent? e.g. <div class="formstyle"> <label for="state">Exam Level</label> <select id="state" class="pure-input-1-2"> <option>Level 1</option> <option>Level 2</option> <option>Level 3</option> </select> </div> 3. Is the code in my asp file correct, or can I change it to: <%Set myMail=CreateObject("CDO.Message")myMail.Subject="Exam Registration"myMail.From="issuetr@digicore.co.za"myMail.To="issuetr@digicore.co.za"myMail.TextBody="This is a message."myMail.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/sendusing")=2'Name or IP of remote SMTP servermyMail.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"'Server portmyMail.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25myMail.Configuration.Fields.UpdatemyMail.SendResponse.Write("Mail Sent!")'Destroy the mail object!set myMail=nothing%> I REALLY appreciate your help!!! Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 5, 2014 Report Share Posted August 5, 2014 Does the <input type="text" name="user_email_address"> go into my html file, and the Request.Form("user_email_address") into my seperate .asp file?Right. The HTML form says how to submit the data, that's what the input names are for. The data will be submitted with that name. In ASP, you get the data using the same name with which it was submitted.How do I code the input on the parts of the form, like the calendar and dropdown list, to obtain those values to go into the mail that is automatically sent?The same way, with a name attribute. A select element, textarea, input, etc all can (and should) have a name attribute. For a select element, the value that gets submitted will be the value of the option that they chose.Is the code in my asp file correct, or can I change it to:The new code looks fine, but it doesn't use any of the form data. You can fill out the email body with the contents of Request.Form to add the data they submitted. Quote Link to post Share on other sites
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.