Hi I had a login script in php, Mysql. Users can make their accounts and they can add their property in my database. I need to do a mail to all of the other users when an user add a property. Kindly Let me know about the script. I had a column in the database named "emailid" inwhich users email ids storred. Please help me how can I do it.
Thanks in advance
To get specific fields (i.e. your emailid field from the database) you request it via a mysql_query and then assign the query to a mysql_fetch_object function which as described on the PHP website:
Fetch a result row as an object
Obviously a row is the same as a field in this case. So here's the code you need:
<?php $query=mysql_query("SELECT username,emailid FROM users WHERE username = '$username'"); $object=mysql_fetch_object($query); mail($object->emailid,'Subject here','Message here'); // more info on this function: http://uk.php.net/manual/en/function.mail.php echo $object->emailid; // this will echo the users email ID as corresponding to your database. $object-> simply is calling the fields it can corresponding to the query we made, such as $object->emailid; ?>
...I presume you're using cookies or sessions and $username has the users' username in it from the cookie/session or form.