Jump to content

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 = "julie.birdsong@gmail.com";

$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 = "julie.birdsong@gmail.com";
$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 = "julie.birdsong@gmail.com";
$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 = "julie.birdsong@gmail.com";


// 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 = "julie.birdsong@gmail.com";
$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 = "julie.birdsong@gmail.com";
$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>");
}
?>

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.