Jump to content

Recommended Posts

I'm making a simple mailer program that uses SmtpClient() and I've got my form set up with a to, from, subject, and body field, along with a button to send it.  I've set up a few if...then statements at the beginning to catch whether the person has put in information for all the required fields (to and from) and confirms if they want to send the message without a subject or body.  Well that works just fine, I get a messagebox if I don't enter one of those values...but the code keeps processing.  How can I kill it and return the user back to the form if they don't put anything in the to or from field?  Right now a user could enter in a to email, from email, no subject, and a body; the script would prompt if they wanted to send the message without a subject.  I could hit no, but it'd still send.  How can I make it so that the code stops in it's tracks when all required information isn't put in, or if the user says no when asked if they want to send without a subject or body?

Link to comment
https://forums.phpfreaks.com/topic/182307-pause-a-method-until-a-condition-is-met/
Share on other sites

  • 2 weeks later...

Well, we're not sure what language you're wanting to write this in but I will tell you in PHP and you can convert.

 

 

Assuming you have 3 textboxes and a submit button...

 

if ($submit_btn)
{
     // You would write a bunch if IF conditionals to see if each value has been passed in
     if ($textbox1)
     {
           if ($textbox2)
           {
                  if ($textbox3)
                  {
                       //Process request here
                   } 
                   else { //redirect for try-again }
            } 
            else { //redirect for try-again }
     } 
     else { //redirect for try-again }

}

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.