Hello guys,

after some searching and playing around and ofcourse with alot of help. i have got this code, which basically GETs ID from browser and then sends them an email, but why isnt it working, can some one please show me why.
thank you

<?php 
    $con = mysql_connect("localhost", "t", "4545"); 
    if (!$con) 
        { 
            die('could not connect: ' . mysql_error()); 
        } 
    mysql_select_db("t",$con); 
        if(isset($_GET['ID'])){ 
                $result = mysql_query("SELECT EMail from t_table WHERE ID = '".$_GET['ID']."' LIMIT 1"); 
                } 
                $row = mysql_fetch_assoc($result);                 
                    $to = ['EMail']; 
                    $subject = "My subject"; 
                    $message = "Hello world!"; 
                    mail($to,$subject,$message); 
    mysql_close($con); 
?>

Thank you for your assistance

Member Avatar for diafol

Hello guys,

after some searching and playing around and ofcourse with alot of help. i have got this code, which basically GETs ID from browser and then sends them an email, but why isnt it working, can some one please show me why.
thank you

<?php 
    $con = mysql_connect("localhost", "t", "4545"); 
    if (!$con) 
        { 
            die('could not connect: ' . mysql_error()); 
        } 
    mysql_select_db("t",$con); 
        if(isset($_GET['ID'])){ 
                $result = mysql_query("SELECT EMail from t_table WHERE ID = '".$_GET['ID']."' LIMIT 1"); 
                } 
                [B]$row = mysql_fetch_array($result);                 
                    $to = $row['EMail'];[/B] 
                    $subject = "My subject"; 
                    $message = "Hello world!"; 
                    mail($to,$subject,$message); 
    mysql_close($con); 
?>

Thank you for your assistance

Try that. However, getting info straight from the querystring and not validating/cleaning before use in a DB call is a little dangerous.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.