Hello,
I have PHP code that updates a record in my database. I need to run that code when an <a href="mailto....>
link is clicked on, before the email client runs. Thanks for the assistance.
ronhymes
0
Newbie Poster
Recommended Answers
Jump to PostHow about something like:
<a href="/mail-to.php?email=hello@world.co.uk" title="Email hello@world.co.uk">hello@world.co.uk</a> # mail-to.php // Retrieve email address $email = isset($_GET['email']) ? $_GET['email'] : false; // Validate email address? // Update database if($email) header("location: mailto:{$email}"); die('Invalid email address');
Jump to PostHi,
In your html:
<a href='send_email.php?email=contact@site.com'>Contact us</a>
In your php (send_email.php) :
<?php $email = $_GET['email']; // get the email address send_data_to_db(); // save data in db echo 'your text here !'; // echo text echo '<a href="mailto:'.$email.'"> Your text here to open …
All 7 Replies
blocblue
238
Posting Pro in Training
Featured Poster
Dani
commented:
I was going to suggest using a jQuery hook onto the mailto link to run an AJAX query, but your way is much more direct!
+14
ronhymes
0
Newbie Poster
blocblue
238
Posting Pro in Training
Featured Poster
ronhymes
0
Newbie Poster
blocblue
238
Posting Pro in Training
Featured Poster
akmozo
5
Light Poster
ronhymes
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.