Jump to content


Photo

Php emailer help


  • Please log in to reply
7 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 18 August 2006 - 01:42 PM

i cant seem to figure out what is going wrong im sure it is something simple

but the email function is not working

<div align="center">
<form name="form1" method="post" action="">
  <p>Your Name:<br>
    <input name="name" type="text" size="50">
  </p>
  <p>Your Email:<br>
    <input name="from" type="text" size="50">
  </p>
  <p>Your Question:<br>
    <textarea name="contents" cols="50" rows="5"></textarea>
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">  
    </p>
</form></div>

<?php

if(isset($_POST['Submit'])){}else{

$to = "2fr3sh@gmail.com";
$subject = "Question from DoitYourself";
$from_header = "From: $from";
 

   mail($to, $subject, $contents, $from_header);



echo "Thank You for using the 2fr3sh emailer the messages have been sent!";
};

?>


#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 18 August 2006 - 01:46 PM

you have your isset function wrong. Also if you have globals turned off, which they are by default, you cannot just use $from.

try this
<?php
if(isset($_POST['Submit'])){
$to = "2fr3sh@gmail.com";
$subject = "Question from DoitYourself";
$from_header = "From: $_POST['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 name="form1" method="post" action="">
  <p>Your Name:<br>
    <input name="name" type="text" size="50">
  </p>
  <p>Your Email:<br>
    <input name="from" type="text" size="50">
  </p>
  <p>Your Question:<br>
    <textarea name="contents" cols="50" rows="5"></textarea>
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">  
    </p>
</form></div>

<?
}
?>



#3 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 18 August 2006 - 01:49 PM

<form name="form1" method="post" action="">

You have not defined action in your form, so the data you submit doesn't get sent anywhere. Try this:

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">


#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 18 August 2006 - 01:50 PM

good job heyray2 I blew right past that part :)

#5 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 18 August 2006 - 01:50 PM

worked perfectly thank you

#6 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 18 August 2006 - 01:52 PM

Glad to help... ;)

#7 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 18 August 2006 - 01:55 PM

i wouldnt recommend putting
<?php echo $_SERVER['PHP_SELF']; ?>
because it just goes to the main page index.php not to the page i want it to stay on

leaving the action blank makes the same page reload allowing the script to work now

#8 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 18 August 2006 - 02:05 PM

<?php echo $_SERVER['PHP_SELF']; ?>

That variable is replaced by the name of the php file that printed out your html form, so only use it if that same php file also does your form processing.

Otherwise, enter the name of the file that you want to process the form... ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users