deepson2 Posted June 19, 2009 Share Posted June 19, 2009 Hello, I am just slightly confused about how can i do the following? Actually i have form where user can shout on other users profile like hello,or anything else. now i want to send notification mail to the user who's getting that shout. so i am just confused about how i can achieve this at a time if($_POST['shout'] == "Shout"){ $to = $_POST['to']; $from = $_POST['from']; $message = $_POST['message']; $messagesql = $op->insert("INSERT INTO ".tbl_message." (toid,fromid,message,date) VALUES ('".$to."','".$from."','".$message."','".date('Y-m-d:h:i')."')"); if($messagesql > 0){ $err_msg_shout="Shout Posted"; else{ $err_msg_shout="Error, Try Again"; } }} now question is where i can put this my mail code so both the things would be getting done at a same time,like 1) show message that shout is posted 2)mail is sent(though i wont show it once this is done,but as of now to check its working or not that why want to echo this message also I know pretty silly question but i am got stucek with it can anyone help me? thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/162891-show-the-messege-as-well-as-send-notification-mail-both-at-a-time/ Share on other sites More sharing options...
joel24 Posted June 19, 2009 Share Posted June 19, 2009 you can use javascript to call a PHP page which checks if theres any new shouts every say 10minutes? or just wait and have it done on every page refresh... i'd probably just have the script check if there were any messages in the tbl_message / whatever this converts to table which were had the users ID as the toid and had not been viewed yet (viewed = 0) if there were, i'd display the messages and at the same time set a "viewed" column in the tbl_message table to "1" Quote Link to comment https://forums.phpfreaks.com/topic/162891-show-the-messege-as-well-as-send-notification-mail-both-at-a-time/#findComment-859481 Share on other sites More sharing options...
deepson2 Posted June 19, 2009 Author Share Posted June 19, 2009 thanks for your reply joel24, you can use javascript to call a PHP page which checks if theres any new shouts every say 10minutes? or just wait and have it done on every page refresh... I dont think i need java script here. and this 10 minutes logic. the thing is i only want as soon as i have got record in messege table send that user to reply. like all these forum works. if we got any PM/reply on post we get mail. i just want to do something like that. can you help me? Quote Link to comment https://forums.phpfreaks.com/topic/162891-show-the-messege-as-well-as-send-notification-mail-both-at-a-time/#findComment-859484 Share on other sites More sharing options...
Dathremar Posted June 19, 2009 Share Posted June 19, 2009 if($_POST['shout'] == "Shout"){ $to = $_POST['to']; $from = $_POST['from']; $message = $_POST['message']; $messagesql = $op->insert("INSERT INTO ".tbl_message." (toid,fromid,message,date) VALUES ('".$to."','".$from."','".$message."','".date('Y-m-d:h:i')."')"); if($messagesql > 0){ // add mail function here $err_msg_shout="Shout Posted: ".$message; // displaying the message else{ $err_msg_shout="Error, Try Again"; } }} and for sending mail use mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/162891-show-the-messege-as-well-as-send-notification-mail-both-at-a-time/#findComment-859490 Share on other sites More sharing options...
deepson2 Posted June 19, 2009 Author Share Posted June 19, 2009 Dathremar, i know how to use mail function. you are not understanding what i exactly want. suppose A shouted on B's profile. when he/she did this,he/she ll get the message which ll says shout is posted. and notification mail would be sent to B that he/she's got new shout. so my question is how can i do insertion as well as my notification at same time any help? Quote Link to comment https://forums.phpfreaks.com/topic/162891-show-the-messege-as-well-as-send-notification-mail-both-at-a-time/#findComment-859509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.