I am a php newbie, but I'm trying to learn and I have been trying to fix this issue for over a week with loads of variations tried.
Short story - I query a db for an email address that I want to use in a form mail() function. I can echo the email on the page (just to check I'm querying OK).. but no email is sent. I've read all the php tutorial pages and hundreds of forums posts, I think that my issue is that $cemail is an object not a string?
On the mail() function I have 2 lines, one using the $cemail and one going to a fixed address. I receive the fixed address email, so I know the form is working.
The post form send verification reports an empty variable though - :(
Your message was sent to us successfully. ><
// retrieve link data
$userid = $_GET['userid'];
// connect to DB
$con=mysqli_connect("xxxxx","xxxxx","xxxxxx","xxxxxxxxx");
$result = mysqli_query($con,"SELECT email FROM wp_participants_database WHERE id = '$userid'");
$row = mysqli_fetch_array($result);
$cemail = $row['email'];
{
echo $cemail;
}
......
mail($cemail,$subject,$emailbody,$headers);
mail("example@email.com",$subject,$emailbody,$headers);
?>
<div>
<p class="alert alert-success"><?php _e('Your message was sent to us successfully. >' . $cemail .'<', _THEME); ?></p>
This is a site I'm creating for the wife... and I've spent many hours banging my head against this already - any help is much appreciated! :)
Thanks