| | |
PHP echo email address as mailto
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi,
I'm sure this is very simple but am unable to find out how.
How do I display an email address as a mailto link like in HTML? I have records displayed from a mysql db but would like to display a member email address that acts as a mailto link. Below displays the code that echos the value but of course I would like the value (email address) to function as a mailto link in HTML
Thanks in advance.
I'm sure this is very simple but am unable to find out how.
How do I display an email address as a mailto link like in HTML? I have records displayed from a mysql db but would like to display a member email address that acts as a mailto link. Below displays the code that echos the value but of course I would like the value (email address) to function as a mailto link in HTML
php Syntax (Toggle Plain Text)
<?php echo $row_master_view['email']; ?>
•
•
Join Date: Sep 2009
Posts: 521
Reputation:
Solved Threads: 61
0
#2 21 Days Ago
I assume you want to mail on click of this link, if so, execute the php script to send a mail using ajax on click of this link.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
0
#3 21 Days Ago
That's right. I want to open the users email client to send mail, as the mailto function does in HTML. Could you modify the code or provide an example of how this is done? Thanks for your quick response.
•
•
Join Date: Sep 2009
Posts: 521
Reputation:
Solved Threads: 61
-1
#4 21 Days Ago
PHP Syntax (Toggle Plain Text)
var req = createXMLHttpRequest(); function createXMLHttpRequest() { var ua; if(window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if(window.ActiveXObject) { try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } function sendRequest() { //var rnd982g = Math.random(); // var str = ""; var url= 'send_mail.php'; if(document.getElementById('txtName') !='' && document.getElementById('txtName') != null) { url +="?name="+document.getElementById('txtName').value; } if(document.getElementById('txtMail') !='' && document.getElementById('txtMail') != null) { url +="&id="+document.getElementById('txtName').value; }else { alert("enter email address"); return false; } if(document.getElementById('txtBody')!='' && document.getElementById('txtBody')!=null) { url+="&body="+urldocument.getElementById('txtBody').value; }else { alert("email body is empty"); return false; } req.open('GET', url); req.onreadystatechange = handleResponse; req.send(null); return false; } function handleResponse() { if(req.readyState == 4){ var response = req.responseText; document.getElementById("results").innerHTML = response; } } </script> <? ?> <html> <head></head> <body> <form name="frm" id="frm" method="post" target=""> <table> <tr><td>Name</td><td><input type="text" name="txtName" id="txtName" /></td></tr> <tr><td>Email Address</td><td><input type="text" name="txtMail" id="txtMail" /></td></tr> <tr><td>Body</td><td><textarea name="txtBody" id="txtBody" ></textarea></td></tr> <tr><td><input type="submit" value="Send Mail" onclick="sendRequest();" /></td></tr> </form> </body> </html>
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 521
Reputation:
Solved Threads: 61
-1
#5 21 Days Ago
Now save this as send_mail.php-
PHP Syntax (Toggle Plain Text)
<? $name = $_GET['name']; $email_id = $_GET['id']; $body = $_GET['body']; $subject = "This is the subject"; if(mail($email_id,$subject,$body)) { echo "Done"; } else{ echo "Failed";} ?>
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
1
#6 21 Days Ago
Why not let the browser handle it:
php Syntax (Toggle Plain Text)
<?php echo '<a href="mailto:' . $row_master_view['email'] . '">' . $row_master_view['email'] . '</a>'; ?>
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Sep 2009
Posts: 521
Reputation:
Solved Threads: 61
-1
#7 21 Days Ago
yes, its cool too, but the process by ajax will be done in the backend.
page won't refresh while sending the mail.
page won't refresh while sending the mail.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
0
#8 21 Days Ago
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
0
#9 20 Days Ago
•
•
•
•
Why not let the browser handle it:
php Syntax (Toggle Plain Text)
<?php echo '<a href="mailto:' . $row_master_view['email'] . '">' . $row_master_view['email'] . '</a>'; ?>
![]() |
Similar Threads
- How to echo html code in php echo (PHP)
- Email address showing as mailto link on webpage (PHP)
- Password Encryption (MySQL)
- PHP and Checkboxes in email (PHP)
- check if email address is correct without sending email? (PHP)
- Protecting email address from robots (PHP)
Other Threads in the PHP Forum
- Previous Thread: how ro grab discription from oteh website in php?
- Next Thread: session in php
| Thread Tools | Search this Thread |
apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code cron curl database dataentry date display duplicates dynamic ebooks echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google href htaccess html image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu mlm multiple mysql number oop paypal pdf php phpincludeissue problem query radio random recursion recursive remote script search server sessions shot sms source sp space speed sql subdomain subscription syntax system table tag tutorial tutorials update upload url validator variable vbulletin video web white youtube





