Jump to content

Archived

This topic is now archived and is closed to further replies.

perezf

Form Emailer -- Stop Process

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

Share this post


Link to post
Share on other sites
You have to make a similar check for all the fields as you have done for the submit:
if(isset($_POST['Submit']))

Share this post


Link to post
Share on other sites
Add another check on one of the other fields

[code]if(isset($_POST['Submit']) && isset($_POST['email'])){[/code]

Ray

Share this post


Link to post
Share on other sites
so it would look something like this
if(isset($_POST['Submit']) && isset($_POST['email']) && isset($_POST['from']) && isset($_POST['contents'])){

because it still doesnt work

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
!empty is kinda the same as isset...

Share this post


Link to post
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'

Share this post


Link to post
Share on other sites

×

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.