Jump to content

Form Emailer -- Stop Process


perezf

Recommended Posts

I currently have an emailer which emails fine without a problem

but when you click submit it submits even though they didnt fill out some fields
can someone please help

[code]<?php

if(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] ???
Link to comment
Share on other sites

Perhaps you should try something like this:

[code]<?php

if(!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.
Link to comment
Share on other sites

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]<?php

if (
  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'
Link to comment
Share on other sites

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.