php发送系统消息,如何使用PHP消息系统向多个用户发送消息

//We check if the user is logged

if(isset($_SESSION['phone']))

{

$form = true;

$otitle = '';

$orecip = '';

$omessage = '';

//We check if the form has been sent

if(isset($_POST['title'], $_POST['recip'], $_POST['message']))

{

$otitle = $_POST['title'];

$orecip = $_POST['recip'];

$omessage = $_POST['message'];

$orecip = implode(' ,', $_POST['recip']);

echo $orecip;

//We remove slashes depending on the configuration

if(get_magic_quotes_gpc())

{

$otitle = stripslashes($otitle);

$orecip = stripslashes($orecip);

$omessage = stripslashes($omessage);

}

//We check if all the fields are filled

if($_POST['title']!='' and $_POST['recip']!='' and $_POST['message']!='')

{

//We protect the variables

$title = mysqli_real_escape_string($conn, $otitle);

$recip = mysqli_real_escape_string($conn, $orecip);

$message = mysqli_real_escape_string($conn, nl2br(htmlentities($omessage, ENT_QUOTES, 'UTF-8')));

//We check if the recipient exists

$dn1 = mysqli_fetch_array($conn->query('select count(id) as recip, id as recipid, (select count(*) from pm) as npm from registrationform where email="'.$recip.'" '));

if($dn1['recip']>=1)

{

//We check if the recipient is not the actual user

if($dn1['recipid']!=$id1)

{

$id = $dn1['npm']+1;

//We send the message

if($conn->query('insert into pm (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values("'.$id.'", "1", "'.$title.'", "'.$id1.'", "'.$dn1['recipid'].'", "'.$message.'", "'.time().'", "yes", "no")'))

{

?>

The message has successfully been sent.

of my personnal messages

$form = false;

}

else

{

//Otherwise, we say that an error occured

$error = 'An error occurred while sending the message';

}

}

else

{

//Otherwise, we say the user cannot send a message to himself

$error = 'You cannot send a message to yourself.';

}

}

else

{

//Otherwise, we say the recipient does not exists

$error = 'The recipient does not exists.';

}

}

else

{

//Otherwise, we say a field is empty

$error = 'A field is empty. Please fill of the fields.';

}

}

elseif(isset($_GET['recip']))

{

//We get the username for the recipient if available

$orecip = $_GET['recip'];

}

if($form)

{

//We display a message if necessary

if(isset($error))

{

echo '

'.$error.'
';

}

//We display the form

?>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值