uramagget Posted July 14, 2007 Share Posted July 14, 2007 <? include "top.txt"; // get posted data into local variables $username = Trim(stripslashes($_POST['username'])); $email = Trim(stripslashes($_POST['email'])); $password = Trim(stripslashes($_POST['password'])); $subdomain = Trim(stripslashes($_POST['subdomain'])); $currenturl = Trim(stripslashes($_POST['currenturl'])); //Send to, and subject. $emailto = "rindiny@pokerindin.com"; $subject = "PokeRindin Hosting"; // Check if filled in/empty if (Trim($email)==""){ echo "You forgot to fill in your E-Mail"; } elseif (Trim($username)==""){ echo "You forgot to fill in your Username"; } elseif (Trim($password)==""){ echo "You forgot to fill in your Password"; } elseif (Trim($subdomain)==""){ echo "You forgot to fill in your Subdomain"; } // prepare email body text $Body = ""; $Body .= "Username: "; $Body .= $username; $Body .= "\n"; $Body .= "Password: "; $Body .= $password; $Body .= "\n"; $Body .= "Sub-domain: "; $Body .= $subdomain; $Body .= "\n"; $Body .= "Current URL: "; $Body .= $currenturl; $Body .= "\n"; // send email $success = mail($emailto, $subject, $Body, "From: <$email>"); // redirect to success page if ($success){ echo "Your application was sent to Rindiny, and is awaiting approval. Can you join our forum while you wait, please?"; } else{ echo "Eeek! the form couldn't go through right. Only one thing to do. Contact Rindiny(rindiny@pokerindin.com), or try the form again. D: "; } include "bottom.txt"; ?> I'm trying to write a form where it makes users require them to fill it in, though even with the if code, the form is submitted, so I can't find out why this doesn't work. Quote Link to comment Share on other sites More sharing options...
lur Posted July 14, 2007 Share Posted July 14, 2007 When finding a required field is empty, the only action you take is printing an error message. If you want to stop the remaining code from executing you must cause it to do so by using, for example, exit(); Quote Link to comment Share on other sites More sharing options...
uramagget Posted July 14, 2007 Author Share Posted July 14, 2007 So I add exit(); inside of every part that checks for empty fields like this? if (Trim($email)==""){ echo "You forgot to fill in your E-Mail"; exit(); } like this? Also, why don't I use die, instead of exit? Quote Link to comment Share on other sites More sharing options...
sinisake Posted July 14, 2007 Share Posted July 14, 2007 you can use die() too... Quote Link to comment Share on other sites More sharing options...
uramagget Posted July 14, 2007 Author Share Posted July 14, 2007 Let me try that. Quote Link to comment Share on other sites More sharing options...
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.