hey im looking for some html code for send to a friend so i can put it on my site, i just wanna little one that you can click, if u kno of any please let me kno

Dani AI

Generated

Two practical options address 's request. A single clickable control can be a mailto link (no server code). For a reliable, trackable "recommend to a friend" feature that actually sends mail from the website, a small server-side form + mail script is required. 's pointer to an "Email this Page" control is the server-side pattern in action, and is correct that client-only code cannot send mail on its own.

A minimal client-side (mailto) option — very small, but dependent on the visitor's mail client:

<a href="mailto:?subject=Check%20out%20this%20page&body=I%20thought%20you%20might%20like%20this:%20https%3A%2F%2Fexample.com">Send to a friend</a>

Pros: zero server work. Cons: opens the visitor's mail program, no tracking, inconsistent on mobile/webmail, limited content length.

A simple server-side pattern (safer and more flexible): a tiny form that posts page info and a server script that validates inputs, strips CR/LF to prevent header injection, and sends the message.

<form action="send.php" method="post">
  <input type="hidden" name="page_url" value="https://example.com/current-page">
  <input type="text" name="your_name" placeholder="Your name" />
  <input type="email" name="your_email" placeholder="Your email" />
  <input type="email" name="friend_email" placeholder="Friend's email" />
  <textarea name="message" placeholder="Optional message"></textarea>
  <button type="submit">Send</button>
</form>
<?php
function clean($s){ return preg_replace("/[\r\n]+/", '', trim($s)); }
$from_name  = clean($_POST['your_name'] ?? '');
$from_email = clean($_POST['your_email'] ?? '');
$to_email   = clean($_POST['friend_email'] ?? '');
$page_url   = trim($_POST['page_url'] ?? '');
$user_msg   = trim($_POST['message'] ?? '');

if(!filter_var($from_email, FILTER_VALIDATE_EMAIL) || !filter_var($to_email, FILTER_VALIDATE_EMAIL)){
  die('Invalid email address.');
}

$subject = 'Recommendation from ' . ($from_name ?: 'a friend');
$body = "$from_name recommends this page:\n\n$page_url\n\nMessage:\n$user_msg\n";
$headers  = "From: no-reply@yourdomain.com\r\n";
$headers .= "Reply-To: $from_email\r\n";

if(mail($to_email, $subject, $body, $headers)) { echo 'Sent.'; } else { echo 'Failed.'; }
?>

Important production notes: set From to a site-controlled address (avoid forging arbitrary From headers), always strip CR/LF from headers, validate emails with filter_var, rate-limit sends per IP/session, add a CAPTCHA or other anti-abuse checks, and prefer authenticated SMTP (PHPMailer or similar) for reliable delivery. Test mail behavior on a real server — mail() often behaves differently on localhost.

Recommended Answers

All 3 Replies

I'm unclear what it is you're asking. You want to send some HTML code to a friend? Please clarify!

Also, since this is a professional forum, we expect a professional style of speech/language. Please strive to use proper punctuation and conventional spelling - one shouldn't have to decipher your messages or guess at what you're asking.

Near the top of this page, look in the pale yellow area below the Post Reply button. See where it says Email this Page? Click that link. He is looking for something that does that for his site. (Allows web surfers to recommend his site to friends by filling in a form)

I see. Ok, that needs to be asked in the appropriate server-side forum, doesn't it? You can't perform an email operation in client-side code.

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.