perezf Posted August 18, 2006 Share Posted August 18, 2006 I currently have an emailer which emails fine without a problembut when you click submit it submits even though they didnt fill out some fieldscan someone please help[code]<?phpif(isset($_POST['Submit'])){$to = "$email";$subject = "$idea";$from_header = "From: $from"; mail($to, $subject, $contents, $from_header);echo "Thank You for using the 2fr3sh emailer the messages have been sent!";}else{ ?><div align="center"><form action="" method="post"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="padding-left:10px;"> <tr> <td height="53"> <div align="left"><font color="black">Subject:</font><font color="#000000"><br> </font> <input name="idea" type="text" id="idea" size="50"> <br> </div></td> </tr> <tr> <td height="51"> <div align="left"><font color="black">To Email Address:</font><br> <input name="email" type="text" id="email" size="50"> <br> </div></td> </tr> <tr> <td height="50"> <div align="left"><font color="black">From Email Address:</font><br> <input name="from" type="text" id="from" size="50"> <br> </div></td> </tr> <tr> <td> <div align="left"><font color="black">Message:</font><br> <textarea name="contents" cols="44" rows="5" id="contents"></textarea> </div></td> </tr> <tr> <td><div align="center"> <br> <input type="Submit" value="Send Email" name="Submit"> <input type="reset" value="Reset Form"> </div></td> </tr> </table> </form></div><?php};?>[/code] ??? Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 18, 2006 Share Posted August 18, 2006 You have to make a similar check for all the fields as you have done for the submit:if(isset($_POST['Submit'])) Quote Link to comment Share on other sites More sharing options...
craygo Posted August 18, 2006 Share Posted August 18, 2006 Add another check on one of the other fields[code]if(isset($_POST['Submit']) && isset($_POST['email'])){[/code]Ray Quote Link to comment Share on other sites More sharing options...
perezf Posted August 18, 2006 Author Share Posted August 18, 2006 so it would look something like thisif(isset($_POST['Submit']) && isset($_POST['email']) && isset($_POST['from']) && isset($_POST['contents'])){because it still doesnt work Quote Link to comment Share on other sites More sharing options...
Woolf Posted August 18, 2006 Share Posted August 18, 2006 Perhaps you should try something like this:[code]<?phpif(!empty($_POST['idea']) && !empty($_POST['email']) && !empty($_POST['contents']) && isset($_POST['Submit'])){$to = "$email";$subject = "$idea";$from_header = "From: $from"; mail($to, $subject, $contents, $from_header);echo "Thank You for using the 2fr3sh emailer the messages have been sent!";}else{ ?>[/code]In theory, that should work. Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 20, 2006 Share Posted August 20, 2006 !empty is kinda the same as isset... Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 21, 2006 Share Posted August 21, 2006 you shoudl use isset because it is much more flexible when changing scripts.... perez nearly go it right...You can use isset for all the variables you need like so...[code]<?phpif ( isset( $_POST['email'], $_POST['from'], $_POST['contents'] ) ){....?>[/code]Now as you can see if you need to add another variable that must be filled in it is mereley a case of adding the new var to the list in the isset construct.$_POST['email']) && isset($_POST['from']) && isset($_POST['contents' 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.