jrodd32 Posted October 9, 2006 Share Posted October 9, 2006 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:[email protected],[email protected],[email protected]?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]; ?> "> Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/ Share on other sites More sharing options...
Orio Posted October 9, 2006 Share Posted October 9, 2006 This is a bit messy... Are you sure this is how it looks or maybe the forum made it look this way?Orio. Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106350 Share on other sites More sharing options...
redarrow Posted October 9, 2006 Share Posted October 9, 2006 Wheres the code lol. Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106351 Share on other sites More sharing options...
jrodd32 Posted October 9, 2006 Author Share Posted October 9, 2006 <a href="mailto:[email protected],[email protected],[email protected]?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 Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106353 Share on other sites More sharing options...
redarrow Posted October 9, 2006 Share Posted October 9, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106356 Share on other sites More sharing options...
jrodd32 Posted October 9, 2006 Author Share Posted October 9, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106360 Share on other sites More sharing options...
kenrbnsn Posted October 9, 2006 Share Posted October 9, 2006 When posting your code prefix your code with [nobbc][code]<?php[/nobbc] and end it with [nobbc]?>[/code][/nobbc]. If your code contains any Javascript, change any [nobbc]<script>[/nobbc] tags to [nobbc]< script >[/nobbc]Ken Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106366 Share on other sites More sharing options...
jrodd32 Posted October 9, 2006 Author Share Posted October 9, 2006 trying again...[code]<html><a href="mailto:[email protected],[email protected],[email protected]?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 Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106371 Share on other sites More sharing options...
Daniel0 Posted October 9, 2006 Share Posted October 9, 2006 What error do you get? Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106374 Share on other sites More sharing options...
jrodd32 Posted October 9, 2006 Author Share Posted October 9, 2006 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 %OAthere should be info where the blank spaces are. Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106377 Share on other sites More sharing options...
kenrbnsn Posted October 9, 2006 Share Posted October 9, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106384 Share on other sites More sharing options...
redarrow Posted October 9, 2006 Share Posted October 9, 2006 it;s best you work with this code ok.[code]<?php$to = '[email protected]';$subject = 'the subject';$message = 'hello';$headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers);?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106387 Share on other sites More sharing options...
redarrow Posted October 9, 2006 Share Posted October 9, 2006 Example only.[code]<?phpforeach($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] Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106392 Share on other sites More sharing options...
jrodd32 Posted October 9, 2006 Author Share Posted October 9, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106396 Share on other sites More sharing options...
redarrow Posted October 9, 2006 Share Posted October 9, 2006 the mail function i provided was from php.net i use and always works for me.good luck. Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106404 Share on other sites More sharing options...
kenrbnsn Posted October 9, 2006 Share Posted October 9, 2006 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 = '[email protected]';$from = "From: Some One <[email protected]\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 Quote Link to comment https://forums.phpfreaks.com/topic/23446-handling-form-data-using-a-mailto-statement/#findComment-106425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.