Jump to content

Smtp Email


Cathryn

Recommended Posts

:rtfm:

Hello,

I am a beginner and i am trying to send an email that shows what weather the person experienced from information they fill out on a form.

This is the form:

 

<html>
   <body>
      <form method="post" action="email.php">
         <p><h2>How is your weather now?</h2></p>
            <p>Please enter your information: </p>
            <p>
               City:<input  type="text" name="city">
               Month:<input  type="text" name="month">
               Year:<input  type="text" name="year">
            </p>
            <p>Please choose the kinds of weather you experienced from the list below.<br>
            Choose all that apply.</p>
            <p>
         <input type="checkbox" value="Sunshine" name="type[]">Sunshine<br>
         <input type="checkbox" value="Clouds" name="type[]">Clouds<br>
         <input type="checkbox" value="Rain" name="type[]">Rain<br>
         <input type="checkbox" value="Hail" name="type[]">Hail<br>
         <input type="checkbox" value="Sleet" name="type[]">Sleet<br>
         <input type="checkbox" value="Snow" name="type[]">Snow<br>
         <input type="checkbox" value="Wind" name="type[]">Wind<br>
         <input type="checkbox" value="Cold" name="type[]">Cold<br>
         <input type="checkbox" value="Heat" name="type[]">Heat<br>
         <input type="checkbox" value="Fog" name="type[]">Fog<br>
         <input type="checkbox" value="Humidity" name="type[]">Humidity
      </p>
      Anything Else? Please list in the additional weather conditions in box, separated by commas.<br>
      <input type="text", name="add" size="50"><br>
         
         <input type=submit name="submit" value="Go">
      </form>
   </body>
</html>

 

 

 

 

and here is the email coding:

 

<?php
if(isset($_POST['email'])) {
     
    $email_to = "[email protected]";
    $email_subject = "<h1>How is your weather now</h1>";
    
    $city = $_POST['city']; 
    $month = $_POST['month']; 
    $year = $_POST['year']; 
    $type = $_POST['type']; 
    $add = $_POST['add']; 
    
    $email_message .= "In ".clean_string($city) . " in the month of "  .clean_string($month).clean_string($year)." you observed the following weather: ""\n";
<?php

$check =0;
$top = array('Sunshine', 'Clouds', 'Rain', 'Hail', 'Sleet', 'Snow', 'Wind', 'Cold', 'Heat', 'Fog', 'Humidity');
                  
foreach ($_POST['type'] as $type){
   echo "<li>$type</li> \r\n";
}

?>
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>

 

 

I keep getting errors on the part where i put the message body of the email.

Any help would be greatly appreciated! :rtfm:

Link to comment
https://forums.phpfreaks.com/topic/240181-smtp-email/
Share on other sites

Please use [[/tt]code] or [[tt]php] tags to post code in the future.

 

Is that exactly how the code appears in your file? Your PHP tags are all messed up. You shouldn't have a "<?php" when you're already inside of a PHP tag. Similarly, you houldn't be using "?>" if you're not intending to get out of PHP.

 

If that's not your problem, what exactly are the errors you're getting?

Link to comment
https://forums.phpfreaks.com/topic/240181-smtp-email/#findComment-1233713
Share on other sites

Even after removing the clean_string() and using the $email_message code is not working.

 

$email_message = "In ".$city . " in the month of " . $month.$year." you observed the following weather: ""\n";

$check =0;
$top = array('Sunshine', 'Clouds', 'Rain', 'Hail', 'Sleet', 'Snow', 'Wind', 'Cold', 'Heat', 'Fog', 'Humidity');

foreach ($_POST['type'] as $type){
echo "<li>$type</li> \r\n";
}

 

Link to comment
https://forums.phpfreaks.com/topic/240181-smtp-email/#findComment-1233732
Share on other sites

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.