Jump to content

Email Submission for Newsletter


julieb

Recommended Posts

I have a newsletter request form with only an email being sent.  For some reason it is not working.  I would really appreciate it, if I could get some help.  Thank you so much in advance.

 

 

Here is the php I have:

 

<?

$to = "[email protected]";

$from_header = "From: $from";

if($contents != "")

{

  //send mail - $textfield come from

 

surfer input

  mail($to, $textfield, $from_header);

  // redirect back to url visitor came

 

from

  header("Location: $HTTP_REFERER");

}

  else

{

  print("<HTML><BODY>Error, no comments

 

were submitted!");

  print("</BODY></HTML>");

}

?>

 

 

 

 

Here is the html code I have:

 

<form action="send_email.php3" method="POST">

 

                <label>

                                                      

                <input type="text" name="textfield" id="textfield" />

                </label>

                <label>

                <input type="submit" name="button" id="button" value="Submit" />

                </label>

                <div align="right"></div>

              </form>         

 

Thank you so much again.  Here is the site that it is on.  http://epistrophikpeachsound.com/links/  at the bottom right.  :)

Link to comment
https://forums.phpfreaks.com/topic/141977-email-submission-for-newsletter/
Share on other sites

Okay, there are a few things that are wrong here

<?php
$to = "[email protected]";
$from_header = "From: $from";
if($contents != "")
{
   //send mail - $textfield come from 

surfer input
   mail($to, $textfield, $from_header);
   // redirect back to url visitor came 

from
   header("Location: $HTTP_REFERER");
}
  else
{
   print("<HTML><BODY>Error, no comments 

were submitted!");
   print("</BODY></HTML>");
}
?>

 

Where is the $from defined in:

$from_header = "From: $from";

 

And the $textfield needs to be $_POST['textfield'] since you're getting it from the form.

 

So:

<?php
// Always be sure to use long tags (<?php, not <?)

// Setup basic info
$to = "[email protected]";
$from_header = "From: $from"; // Where is this coming from?

// Check contents, again where is variable that coming from?
if($contents != "")
{
   //send mail - $textfield come from surfer input
   // dont forget $_POST 
   mail($to, $_POST['textfield'], $from_header);

   // redirect back to url visitor came from
   // This isn't the most secure way, but that's okay for now.
   header("Location: $HTTP_REFERER");
}
  else
{
   print("<HTML><BODY>Error, no comments 

were submitted!");
   print("</BODY></HTML>");
}
?>

 

Hi there.... thank you for responding.  I was just taking a send_email.php3 file that was online and tried to alter it.  So I should take out the $from_header = "From: $from";  Duh, I dont have a "from" field. 

 

<?php
// Always be sure to use long tags (<?php, not <?)

// Setup basic info
$to = "[email protected]";


// Check contents, again where is variable that coming from?
if($contents != "")
{
   //send mail - $textfield come from surfer input
   // dont forget $_POST 
   mail($_POST['textfield']);

   // redirect back to url visitor came from
   // This isn't the most secure way, but that's okay for now.
   header("Location: $HTTP_REFERER");
}
  else
{
   print("<HTML><BODY>Error, no comments 

were submitted!");
   print("</BODY></HTML>");
}
?>

 

I changed it but it is still not working.. the only thing that comes up is "Error, no comments were submitted!"  I put in an email address in the textfield box?? 

 

Not sure what else to do..  THANK YOU SO MUCH...

 

 

 

Okay, there are a few things that are wrong here

<?php
$to = "[email protected]";
$from_header = "From: $from";
if($contents != "")
{
   //send mail - $textfield come from 

surfer input
   mail($to, $textfield, $from_header);
   // redirect back to url visitor came 

from
   header("Location: $HTTP_REFERER");
}
  else
{
   print("<HTML><BODY>Error, no comments 

were submitted!");
   print("</BODY></HTML>");
}
?>

 

Where is the $from defined in:

$from_header = "From: $from";

 

And the $textfield needs to be $_POST['textfield'] since you're getting it from the form.

 

So:

<?php
// Always be sure to use long tags (<?php, not <?)

// Setup basic info
$to = "[email protected]";
$from_header = "From: $from"; // Where is this coming from?

// Check contents, again where is variable that coming from?
if($contents != "")
{
   //send mail - $textfield come from surfer input
   // dont forget $_POST 
   mail($to, $_POST['textfield'], $from_header);

   // redirect back to url visitor came from
   // This isn't the most secure way, but that's okay for now.
   header("Location: $HTTP_REFERER");
}
  else
{
   print("<HTML><BODY>Error, no comments 

were submitted!");
   print("</BODY></HTML>");
}
?>

Archived

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

×
×
  • 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.