Jump to content


Photo

Handling Form Data, using a mailto: statement


  • Please log in to reply
15 replies to this topic

#1 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 October 2006 - 05:25 PM

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];
          ?>
          ">

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 09 October 2006 - 05:29 PM

This is a bit messy... Are you sure this is how it looks or maybe the forum made it look this way?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 October 2006 - 05:29 PM

Wheres the code lol.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 October 2006 - 05:32 PM

<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

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 October 2006 - 05:38 PM

sorry but i dont seem to understand the code as it is on the forum as a link to a email address try to use the code /code tags to see the code properly sorry.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 October 2006 - 05:42 PM

It is not posting what i am putting into the text box area, it is cutting alot of the code off. I will attach the file

[attachment deleted by admin]

#7 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 October 2006 - 05:47 PM

When posting your code prefix your code with [code]<?php and end it with ?>[/code]. If your code contains any Javascript, change any <script> tags to < script >

Ken

#8 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 October 2006 - 05:50 PM

trying again...
<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>

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


#9 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 09 October 2006 - 05:53 PM

What error do you get?

#10 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 October 2006 - 05:57 PM

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.

#11 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 October 2006 - 06:03 PM

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

#12 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 October 2006 - 06:05 PM

it;s best you work with this code ok.

<?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);
?> 


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#13 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 October 2006 - 06:13 PM

Example only.

<?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);

?> 


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#14 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 09 October 2006 - 06:16 PM

I assume that mail function you are using is the one kenrbnsn was refering to?  Also, is: 'X-Mailer: PHP/' . phpversion(); exactally what I need to put or is that individual to my system.

Thanks for the help


#15 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 October 2006 - 06:22 PM

the mail function i provided was from php.net i use and always works for me.

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#16 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 October 2006 - 06:46 PM

Read about the mail() function in the on-line manual.

I have found that the easiest way to send POSTed data in a mail message is to use the print_r() to create the body of the message. For example:
<?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";
}?>

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users