SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JMail / Require Field

    Hi everyone! Can anyone tell me how to require a field in the JMail form? Here's what I have - I jsut want to make the "email_addr" field required:

    HTML Code:
    <%@ LANGUAGE="VBScript" %>
    <%
    
      '-------------------------
      'send mail to this address
    
    
       send_to="webmaster@abccompany.com"
    
    
      '-------------------------
    
    'user info
    fullname=request("fullname")
    email_addr=request("email_addr")
    comments=request("comments")
    
       err_msg=0
       page=Request("page")
    
       if page="" then
         page=1
       else
         page=page+0
       end if
    
    if page=2 then  'send some mail
    
      Set JMail = Server.CreateObject("JMail.SMTPMail") 
                                                 
      JMail.ServerAddress = "mail.abccompany.net:25" 'mail server
    
     
       is_email=split(email,"@")    'parc @
    
       if UBound(is_email)=1 then
         JMail.Sender = email
       else
         JMail.Sender = "webmaster@abccompany.com"
       end if
    
        JMail.Subject = "Comments via WebForm"
    
    
                   
        if send_to <> "" then
         JMail.AddRecipient send_to
        else
         err_msg=1
         err_msg_send=1
        end if
    
        
      'is the ip
      is_ip=Request.ServerVariables("REMOTE_ADDR") 
    
    
      if err_msg <> 1 then       'build message body
    
       JMail.Body = "The following has been submited via the WebForm..."& vbCrLf& vbCrLf
       JMail.AppendText "Full Name: "&fullname& vbCrLf
       JMail.AppendText "Email Address: "&email_addr& vbCrLf       JMail.AppendText "Comments: "& vbCrLf
       JMail.AppendText comments& vbCrLf& vbCrLf& vbCrLf
      end if  'end message body
    
                    ' 1 - highest priority (Urgent)
                    ' 3 - normal
                    ' 5 - lowest
    
      JMail.Priority = 3
    
      JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
      JMail.AddHeader "ABC-Form-Mail", NOW
    
                    ' Send it...
    
     if err_msg <> 1 then
      JMail.Execute  'send the mail
     else 'message not sent
      page=1
     end if
    
    end if
    %>
    <HTML>
    <HEAD>
       <TITLE>Title of Your Page</TITLE>
    </HEAD>
    <BODY>
    
    <!-- End editable portion-->
    
    <%if err_msg=1 then%>
        <table border=0>
         <tr>
          <td bgcolor="#FF5249"><font size="3">
            &nbsp;&nbsp;Error Message</font>
          </td>
         </tr>
         <tr>
          <td bgcolor="#c0c0c0">&nbsp;&nbsp;Oops... There was an error...<br>
            &nbsp;&nbsp;The <b><%=err_where%></b> field is required, Please correct the entry and Send again.<br><br>
            &nbsp;&nbsp;<i>Status: The Message has not been sent...<i><br>
          </td>
         </tr>
        </table>
    <%end if%>
    
    <%if page=1 then 'start page 1%>
    <P>
    <center>
    <FORM METHOD=POST ACTION="mail.asp">
    <TABLE BORDER=1>
    <TR>
    <TD>Your Name:</TD>
    <TD COLSPAN="3"><INPUT NAME="fullname" value="<%=fullname%>"TYPE=text SIZE=33 MAXLENGTH=40></TD>
    </TR>
    <TR>
      <TD>Email address:</TD>
      <TD COLSPAN="3"><INPUT NAME="email_addr" value="<%=email_addr%>" TYPE=text SIZE=33></TD>
    </TR>
    <TR>
     <TD valign=top>Comments:&nbsp;</TD>
     <TD COLSPAN="3">
      <textarea name="comments" rows=4 cols=30 value="<%=comments%>"></textarea>
     </TD>
    </TR>
    <TR><TD COLSPAN=2>
    <TABLE CELLSPACING=3 CELLPADDING=3>
    <TR><TD><input type=reset value="Clear"></TD>
    <TD><INPUT TYPE=submit VALUE="Submit >>">
    <input type=hidden name="page" value="2"></TD></TR>
    </TABLE>
    </TD></TR>
    </TABLE>
    </FORM>
    </CENTER>
    <%end if 'end page 1%>
    
    <%if page=2 then 'start page 2%>
    <font size="4"><b>
    Thank You...<br>
    Your comments have been successfully sent.<p><br>
    We appreciate your business.
    <br>
    Any questions, please call "your phone number here" or email <A HREF="mailto:webmaster@abccompany.com">webmaster@abccompany.com</A>
    </b>
    </font>
    <%end if 'end page 2%>
    </HTML></BODY>
    Glory Lasts Forever.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can either use

    if request.form("email_addr") <> "" then

    run jmail code

    else

    querystring = "?error=1"

    for each item in request.form

    querystring = querystring & "&" & item & "=" & request.form(item)

    loop

    response.redirect = "form.asp" & querystring

    end if


    What this will do, is if it fails, then you can collect all the form data, send it back to the page with the form, and fill the fields with the original data, and the user can edit the missing fields without having to type the rest of the data. Else it sends the data.

    Gav

  3. #3
    SitePoint Enthusiast jenny28's Avatar
    Join Date
    Dec 2004
    Location
    Seattle
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    Thanks Gav!

    My only question is where would I put that code to give it a shot? I'm sorry if I sound dumb asking all these questions, I'm really new to this stuff! I apprectiate all the help!
    Glory Lasts Forever.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •