I have this code:
if(mail($to, $subject, $message, $headers)){
$insert_member_sql = \"INSERT INTO members (id, username) VALUES(\'$id\', \'$username\')\"
change this
if(mysqli_affected_rows($con, $insert_member_res)>0)
to
if(mysqli_affected_rows($con)>0)
mysqli_affected_rows
only requires connection link
object but you passed query object also that was the problem
or you can echo it
echo mysqli_affected_rows($con);
in case you want to double check of course
if(mail($to, $subject, $message, $headers)){
$insert_member_sql = "INSERT INTO members (id, username) VALUES('$id', '$username')";
if (!mysql_query($insert_member_sql) ){
echo "1";
}else{
echo "0";
}
};