Jump to content

Handling Form Data, using a mailto: statement


jrodd32

Recommended Posts

This is a co-problem between php and html so I am not sure where to put it...but anyway...

I am trying to get the information that people are entering into my form into an email that is automatically sent to the proper people upon submit.  However, it is not working properly, it is not picking up the body of the message that I would like it to see.

Here is the code:

<a href="mailto:user1@webmail.khsaa.org,USER2@WEBMAIL.KHSAA.ORG,USER3@WEBMAIL.KHSAA.ORG?subject=<?php
      foreach($source as $concern)
        echo($concern);
        ?>?&body=<?php
          $explaination;
          ?>
          %OA%OA
          <?php
          $row[id];
          ?>
          %OA
          <?php
          $row[lname].$row[suffix].', '.$row[fname];
          ?>
          %OA
          <?php
          $row[homephone];
          ?>
          %OA
          <?php
          $row[workphone];
          ?>
          %OA
          <?php
          $row[email];
          ?>
          ">
Link to comment
Share on other sites

<a href="mailto:jtackett@khsaa.org,MDAY@KHSAA.ORG,JLONG@WEBMAIL.KHSAA.ORG?subject=<?php
      foreach($source as $concern)
        echo($concern);
        ?>?&body=<?php
          $explaination;
          ?>
          %OA%OA
          <?php
          $row[id];
          ?>
          %OA
          <?php
          $row[lname].$row[suffix].', '.$row[fname];
          ?>
          %OA
          <?php
          $row[homephone];
          ?>
          %OA
          <?php
          $row[workphone];
          ?>
          %OA
          <?php
          $row[email];
          ?>
          ">

I must have missed some of it when I copied it...that is how it looks, that might actually be the problem, i am very new to php and having problems when i have to combine it and html
Link to comment
Share on other sites

trying again...
[code]
<html>
<a href="mailto:jtackett@khsaa.org,MDAY@KHSAA.ORG,JLONG@WEBMAIL.KHSAA.ORG?subject=<?php
      foreach($source as $concern)
        echo($concern);
        ?>?&body=<?php
           $explaination;
           ?>
           %OA%OA
           <?php
          $row[id];
          ?>
          %OA
          <?php
          $row[lname].$row[suffix].', '.$row[fname];
          ?>
          %OA
          <?php
          $row[homephone];
          ?>
          %OA
          <?php
          $row[workphone];
          ?>
          %OA
          <?php
          $row[email];
          ?>
          ">
</html>
[/code]

By the way I can print out the data in all the fields of my php variables so I am gettting the information that I want it just isn't getting into the email properly
Link to comment
Share on other sites

I don't get any errors it just isn't sending the email to the people.  And when you hover over the code that is printed to the page it isn't formatted correctly at the bottom of the browser.  Ex.)

mailto:....?&subject=Issue?&body=        %OA%OA      %OA  %OA

there should be info where the blank spaces are.
Link to comment
Share on other sites

You do realize that the mailto href will just open up the client's email program with your information in the message (maybe). It does not send any email, plus the user can see who you're sending the information to and can change it.

It would be much better to use the internal mail function and send the email message directly from your PHP script.

Ken
Link to comment
Share on other sites

it;s best you work with this code ok.

[code]
<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
  'Reply-To: webmaster@example.com' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

[/code]
Link to comment
Share on other sites

Example only.

[code]
<?php

foreach($source as $concern);

$to      = $row['email'];

$subject = 'the subject';

$message = "

<br>

$concern

<br>

$row['id']

<br>

$row['lname'].$row['suffix'].', '.$row['fname']

<br>

$row['homephone']

<br>

$row['workphone']

<br>

$row['email'] ";

<br>

$headers = 'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

?>

[/code]
Link to comment
Share on other sites

Read about the mail() function in the [url=http://www.php.net/manual/en/function.mail.php]on-line manual[/url].

I have found that the easiest way to send POSTed data in a mail message is to use the [url=http://www.php.net/print_r]print_r()[/url] to create the body of the message. For example:
[code]<?php
$to = 'someone@example.com';
$from = "From: Some One <someoneelse@example.com\n";
$Subject = "The follow was just entered";
$bdy = array();
$bdy[] = bdy($_GET,'$_GET');
$bdy[] = bdy($_POST,'$_POST');
$bdy[] = bdy($_SERVER,'$_SERVER);
$body = implode("\n",$bdy) . "\n";
mail($to,$subject,$body,$from);

function bdy($a, $s) {
  $tmp = array();
  if (!$empty($a)) {
      $tmp[] = ' ----- ' . $s . ' ------';
      $tmp[] = print_r($a); }
  return(implode("\n",$tmp)."\n";
}?>[/code]

I put code similar to this at the start of many of my scripts while developing them so I can see whether the scrips are recieving the data I think I'm entering.  It can be an invaluable debugging tool if you are doing any sort of AJAX coding and it can tell you whether hackers are trying to break your scripts.

Ken
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.