sending php email after mysql entry verification

Greetings,

after visitor clicks on a button, I am trying to have my code verify that an mysql entry is set to yes then send the logged-in session user’s email address to the email address associated with that record.

Here is what I have put together:
*left out connect info.

<?php if($_SESSION['id']) $row = mysql_fetch_assoc(mysql_query("SELECT id,usr,member FROM members WHERE usr='{$_POST['username']}'")); if($row['usr']) { $_SESSION['usr']=$row['usr']; $_SESSION['member'] = 'yes'; send_mail( '$_SESSION[emailaddress"]', $_POST['email'], 'Registration System - Your New Password', 'Your password is: '.$email); ?>

[php]if($_SESSION[‘id’]) // missing open bracket [/php]

[php]// stop using deprecated code! Change to mysqli or pdo
mysql_fetch_assoc(mysql_query[/php]

[php]// quotes are messed up
send_mail(’$_SESSION[emailaddress"]’,
// should be
send_mail($_SESSION[‘emailaddress’][/php]

[php] // this bit here is incorrect
send_mail(… 'Your password is: '.$email);[/php]

I think that just about covers everything.
The most important bit of advice is stop using old code. Use Mysqli or PDO and do that first, like today!

Hope that helps,
Red :wink:

I want to ask about this increase.

Sponsor our Newsletter | Privacy Policy | Terms of Service