Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As I said in the comments, the $to_who will have value only if you came from another page (as a querystring) but then your code after if(isset($_POST['submit1'])){ wont work because a GET protocol was used. And if you have this Id on the form that you said the $to_who variable will be empty therefore your query $to_who_raw wont have a result unless you have something in your database with donor_id=''</p> <p>And more, if you came from another page as you said in the comments you will have to have all variables that you use in <code>$_POST</code> as <code>$_GET</code></p> <p>So in order to get both protocols working as you said you have to change your code a little bit. So, it would be something like this:</p> <pre><code>require('connect.php'); $to_who = $_REQUEST['id']; echo $to_who; //Here I'm guessing that you have all variables send // by your FORM OR in a querystring like somepage.php?id=1&amp;subject=adasdad&amp;message=asdasdads if( isset($_POST['submit1']) || isset($_GET['id']) ){ $to_who_search = "SELECT * FROM donorstable WHERE donor_id = '$to_who'"; $to_who_raw = mysql_query($to_who_search); $name = mysql_result($to_who_raw , 0 , 'first_name') . ' ' . mysql_result($to_who_raw , 0 , 'last_name') ; $email = mysql_result($to_who_raw , 0 , 'email'); $getsubject = $_REQUEST['subject']; //see my previous comment $getmessage = $_REQUEST['message']; $getformsql = "SELECT * FROM donorstable WHERE donor_id = '$userid'"; $getfrom = mysql_query($getformsql); //builds email $to = $email; $subject = $getsubject; $message = $getmessage; $from = mysql_result($getfrom , 0 , 'email'); $headers = "From:" . $from; //mail($to,$subject,$message,$headers); echo "Mail Sent."; $inserstatement = "INSERT INTO messages VALUES ('$to_who' , '$from' ,'$subject', '$message' , '0' , '')"; mysql_query($inserstatement); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload