Hi all I am trying to send an email using a 'before record updated' event code. Currently I have this which works perfectly: $email="user@email.com"; $from="donotreply@website.com"; $msg=""; $subject="New Record Added"; $msg.= "Field One: ".$values["Field One"]."\r\n"; $msg.= "Field Two: ".$values["Field Two"]."\r\n"; $ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from)); if(!$ret["mailed"]) echo $ret["message"]; return true; Code (markup): What I would like to do is have $email dynamically filled rather than the hardcoded ''. 'Field Two' is a field that contains the users full name that is the same that data that is held in the 'Full Name' field of the 'Users' table, e.g. Tom Jones. Also in the 'Users' table is another field called 'Email Address'. What do I need to add to the code above to get the script to pull the 'Email Address' from the 'Users' table based on the contents of 'Field Two' which is the same data as 'Full Name' in the 'Users' table?
If you can describe your database structure at least, it would help. Since we don't even know what name of the field with user's email is in your database, it's impossible to provide you with any assistance. If you are looking for just a general answer, it would be: $email=$mysql_row['name_of_field_with_email_address']; PHP:
Thank you. 'Users' is the name of the table and 'Email Address' is the name of the field that contains the email address. The field with the persons name is 'Full Name' in the 'Users' table and 'Field Two' in the record table above. I did add all this in my first post.
So what I want is for it to lookup the users email address from the field 'Email Address' in the 'Users' table based on the data that is in 'Field Two' of the 'Records' table. Basically 'Full Name' in Users = 'Field Two' in Records
Hi this doesn't work. Surely there needs to be some sort of lookup between the name of the person in 'Field Two' (remember this is the 'Records' table) and their associated email address contained in the 'Email Address' field of the 'Users' table.
Sorry, I thought you "extracted" email address before running the mailer script. Please note you also need to "extract" email address (if it's in a different table) before running the mailer, just like you "extract" Records table.
Any help in how to do this would be appreciated. This is my question - I don't know what I need to add to my script above to achieve this? I have added this to the top of the script but it doesn't help:
Now, try to run this exact query via phpmyadmin and you will see what is wrong with your query. Just be sure to replace ".$values["Field Two"]." with actual name you want to fetch. SELECT `Email Address` FROM Users WHERE `Full Name` = ".$values["Field Two"]." Code (markup): Also, your query is very insecure. I could modify or delete records in your database by simply entering some "special" text as my username. You should stop using this type of queries immediately, but I guess it's another story now...
If that there's no possibility of your users to enter values other than given in Users' "Full Name" record (which is a false assumption) then try edit a line in your code on post #8 from: $email="user@email.com, $result"; PHP: to just: $email = $result; PHP: What do you see?
What software are you using? What is this CustomQuery function? Is some other step necessary? How do you get $values variable? What is the var_dump of $result? If you are using PHPRunner I see: $data= db_fetch_array($rs);