Help with sending a link with contact Form email


#1

A web script that I’m using allows a User to upload a video, and then is redirected to a Contact Form, and then submits it. The Contact Form info is then sent via this code(below), to my email address. I’d like help with how to add the link (to the uploaded video file) with a message, to my email address & the User’s email address (that was entered into the Contact Form). Any help will be appreciated:

<?php
//if(isset($_POST['url']) && $_POST['url'] == '')
{
	$youremail = 'contactform@...com';
	$body = "ContactForm:
	Name:  $_POST[name]
	E-Mail: $_POST[email]
	Message: $_POST[message]";

	if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) {
	  $headers = "From: $_POST[email]";
	} else {
	  $headers = "From: $youremail";
	}
	mail($youremail, 'Contact Form', $body, $headers );
}
if(empty($error))
{
header('Location: index.php');
exit;
}
?>

#2

Well, a link is just an HTML anchor. So, you can add it into the message part of the email however you would like it to look. Here is one example of how you can add the link. You would need to customize it the way you wish it to be handled in the email and you would need to know where the video file is stored.

In the $body creation, add this part either before or after the message section:
Video Link: <a href="https://www.YOUR-DOMAIN.com/YOUR-FOLDER/VIDEO-NAME">Press here to play video!</a>

Note you must steer it to your website, the folder you store the video in and the filename of the video including the extentions. So, like /videos/myvideo1.avi or whatever fits your setup. Normally, you would have to move the uploaded file somewhere so you know the folder and file name and have to place it in this line instead of the fake ones I put in. Place your folder variable and filename variable in place of these. Maybe like this:
<a href="https://www.chrisj.com/$folder_name/$video_name">Press here to play video!</a>
Hope that helps…