Jump to content

show the messege as well as send notification mail-both at a time??


deepson2

Recommended Posts

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.

 

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

 

 

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?

Link to comment
Share on other sites

 

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.

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.