I am trying a lot but nothing work for me.
My query is that how to fetch column data from sql database Table and put that data into an string in PHP?
Please check What I am doing.
I have the table "DriveRegisterTable" in which 4 columns in database table, 1st "id" 2nd "username" 3rd "txtMail" 4th "rxtMail" .
Now I want to select txtMail and rxtMail from database table where username = "John"
Now in my database table "username" john have txtMail is " [email protected]" and rxtMail is "[email protected]"
Now I want to fetch these thing on my php string.
Now I want to select txtMail and rxtMail from database table where username = "John" and put txtMail and rxtMail values which are [email protected] and [email protected] in PHP String and then send the mail.
Please check what I am doing it is not working for me:
<?php
$db_host = "localhost";
$username = "jacktask";
$db_pass = "sormor4455";
$database = "myDatabaseDB";
mysql_connect("$db_host", "$username", "$db_pass");
@mysql_select_db($database) or die("Unable to find database4");
$txt_username = $_REQUEST['txt_username']; // here user name is John
$query = mysql_query("SELECT txt_email,rxt_email FROM DriveRegisterTable WHERE txt_username ='$txt_username'");
//$sql = "SELECT txt_email,rxt_email FROM DriveRegisterTable WHERE txt_username ='$txt_username' ORDER BY id ";
$res = mysql_query($query);
if($query){ // Dont know how to send mail or what to write in this condition block
$to = $txt_Mail; // want [email protected] here only but not able to fetch this mail here
$subject = 'Hello Subject!';
$message = 'Hi';
$headers = 'From: $txt_email' . "\r\n" .
'Reply-To: txt_email' . "\r\n" . // want [email protected] here but txt_email does not give any value here means [email protected]
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
mysql_close();
?>
I just want to select [email protected] and [email protected] from John and send mail.
Any Idea or suggestions would be highly welcome.
mysql_queryunder any circumstances. If this application is on the public internet it's vulnerable to SQL injection because of what you've done here.