Jump to content

Recommended Posts

right ive setup my own messaging feature on my website but it still allowes me to message myself if tried

 

<?
}else{
if($to == username){ ?>

 

the whole code so you can get a better understanding

 

<?php
session_start();
include_once "includes/db_connect.php";
include_once "includes/functions.php";
logincheck();
$username=$_SESSION['username'];

$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

if ($fetch->texts < '1'){
echo "<font color=red>You don't have No Texts Left</font><br>";
}elseif($fetch->texts >= '1'){


?> 
<body onLoad="goaway();"><?

$towho=$_GET['fromper'];
$oldmsg=$_GET['oldmsg'];
$text=$_POST['text'];
$subject=$_POST['subject'];
$fsubject=$_GET['fsubject'];
$info=mysql_fetch_object(mysql_query("SELECT rank FROM users WHERE username='$username'"));
$goody = mysql_query("SELECT `inbox`, `date`, `from` FROM `messages` WHERE `id`='$rep'");

while($success = mysql_fetch_row($goody)){
$ini = $success[0];
$dateon = $success[1];
$fromper = $success[2];
}
if(strip_tags($_POST['Send'])){
$text=strip_tags(addslashes($text));
$to = strip_tags(addslashes($_POST['to']));
$rep = $_GET['rep'];
if((!$to)){ ?>
<p class="style4">Please enter a username!</p>

<span class="style4">
<?
}else{
if(!$text){?>
</span>
<p class="style4">You cannot send a blank message!</p>

<span class="style4">
<?
}else{
if($to == username){ ?>
</span>
<p class="style4">You cannot send a message to yourself!</p>

<span class="style4">
<?
}else{
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$to'");
$username_check = mysql_num_rows($sql_username_check);
if ($username_check == 0){ ?>
</span>
<p class="style4">Invalid Username!</p>

<span class="style4">
<? 
}else{
$date = gmdate('Y-m-d H:i:s');
$sql = mysql_query("INSERT INTO `inbox` (`id`, `to`, `from`, `message`, `date`, `read`, `subject`) VALUES ('', '$to', '$username', '$text', '$date', '0', '$subject');") or die (mysql_error());
$sqll = mysql_query("UPDATE users SET texts = texts-1 WHERE username='$username'");
if(!$sql){ ?>
</span>
<p class="style4">There has been an error please contact an Admin !</p>
<span class="style1">
<?
}else{
echo "<table width=300 border=1 align=center cellpadding=0 cellspacing=0 bordercolor=#003300 class=thinline2>
  <tr>
    <td height=20 align=center bgcolor=#74CE59 scope=col><span class=style1>Your Message As Been Sent </span></td>
  </tr>
</table>";
}}}}}}
?>

Link to comment
https://forums.phpfreaks.com/topic/209242-cant-message-your-self/
Share on other sites

right ive setup my own messaging feature on my website but it still allowes me to message myself if tried

 

I have no clue what that means, what you are trying to accomplish, what's wrong, or what this script is supposed to do.  What have you done to narrow the problem down?

 

if($to == username){ ?>

 

should be (and should have thrown and error):

 

if($to == $username){ ?>

right i have sorted this now but i can see what the problem was if my name was Megadust and i sent a message to megadust it would send me a message but if i put Megadust with a capital letter then it wouldnt let me send a message to my self how can i make it so it dont send a message to myself reguardless of captial letters or not.

 

when i say my self i mean for every one who goes on my site not to allow it to send messages to them selfs

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.