Page 1 of 1

MAILER.PHP

Posted: Tue Jan 24, 2006 1:56 pm
by thewebdecorator
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I cant figure out why this isnt working. Maybe a fresh set of eyes will help:

[b]form.html[/b]

Code: Select all

<form name="form1" method="post" action="mailer.php">
              <INPUT TYPE="hidden" NAME="cgiemail-mailopt" VALUE="sync">

  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
    <tr> 
      <td colspan="2"><font face="Verdana, Helvetica, Arial" size="2"><b>APPLICANT 
        BUSINESS INFORMATION</b></font></td>
    </tr>
    <tr> 
      <td width="40%"><font size="2" face="Verdana, Helvetica, Arial">Company 
        Legal Name:</font></td>
      <td width="60%"><font size="2" face="Verdana, Helvetica, Arial"> 
        <input name="Firm_Name" size="30">
        <label>
        <input type="submit" name="Submit" value="Submit">
        </label>
        </font></td>
    </tr>
  </table>
</form>

MAILER.PHP

Code: Select all

<?

  if (!isset($email)) {

    header( "Location: http://www.url.com/form.html" );

  }

  elseif (empty($email)) {

    header( "Location: http://www.url.com/mailer_error.html" );

  }

  else {

mail( "sales@url.com", "Web Inquiry from $name",

"Name: $name
Biz Name: $Firm_Name", "From: $realname <$email>");

header( "Location: http://www.url/mailer_thankyou.html" );

  }

?>
Any ideas?


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Jan 24, 2006 2:12 pm
by ol4pr0
I think you have forgotten the $_POST thingie here :)

Code: Select all

if (!isset($_POST['email'])) { 
    do 
} else {
    do
}
ect...

However you could do all this in one page if you want.

Change the following things like this

Code: Select all

if (isset ($_POST['submit'])) {
 #do processing of your form fields
 if (isset($_POST['email'])) {
 # mail whoever you want to mail or should receive that mail.
 # and display a thank you message
 } else {
 # message that there hasnt been a mail address filled in the form 
 # javascript can validate this easely without redirecting (google.com, search javascript form validation)
 }
} else { # me
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> 
# your form fields go here
</form>
}
Enjoy

Posted: Tue Jan 24, 2006 2:15 pm
by nickman013
also use PHP tags when posting PHP code in the forums.

good luck with your script!