PHP Email on Table Entry

Hi all, my first post here. New to PHP but very keen to pick it all up. I’ve set up an email database. Though I want people to recieve an email once they’ve signed-up basically saying ‘Welcome’. Would be nice if this could be a HTML page.

My code is as below:

  <?php
error_reporting(0);
$name = "";
$email = "";
$msg_to_user = "";
if ($_POST['name']!=""){
	include_once "connection.php";
	
	$name = $_POST['name'];
	$email = $_POST['email'];
	
	$sql = mysql_query("SELECT * FROM newsletter WHERE email='$email'");
	$numRows = mysql_num_rows($sql);
	
	if (!$email){
	$msg_to_user = '<div class="msg_to_user">'.$name.', please type an email address.</div>';
	}
	
	else if ($numRows>0){
	$msg_to_user = '<div class="msg_to_user">'.$email.' is already in the system.</div';
	}
	else {
	$sql_insert=mysql_query("INSERT INTO newsletter (name, email, dateTime) 
	VALUES('$name','$email',now())") or die (mysql_error());
	
	
	$msg_to_user='<div class="msg_to_user">Thanks '.$name.', you have been added successfully.</div></h4>';	
	$name="";
	$email="";
	}
}
?>

Look forward to your help and advice :slight_smile:

Look up the PHP ‘mail’ function would be a start, this will allow you to send mail via your hosts mail system. From there you can start to look into plain text emails, and advance into generating and sending full HTML ones. (You’d put this just after the insert has succeeded).