Jump to content

Php emailer help


perezf

Recommended Posts

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

but the email function is not working

[code]<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!";
};

?>[/code]
Link to comment
Share on other sites

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

<?
}
?>[/code]

Link to comment
Share on other sites

[code]
<form name="form1" method="post" action="">
[/code]

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

[code]
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
[/code]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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... ;)
Link to comment
Share on other sites

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.