Jump to content

stping users adding themselfs


runnerjp

Recommended Posts

how could i stop a user adding themself ??

 

<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
<?php
session_start();
require_once '../settings.php';
checkLogin ('1 2');

if ( !empty($_GET['user']) ) {
if ( ctype_alnum($_GET['user']) && strlen($_GET['user']) <= 10 ) {
  // further test and escape data
}

$user = $_GET['user'];
$get_username_value = get_username($id);
$query = "SELECT * FROM friends WHERE username ='$user' AND friendname='$get_username_value'";
echo $query;
$result = mysql_query($query);
$exist = mysql_num_rows($result);  // Does the row exists?
if($exist=='0')
{
$query = "INSERT INTO friend_requests (username ,by_user) VALUES('$user', '$get_username_value')";
  $result= mysql_query($query)
    or die("QUERY ERROR:<br />{$query}<br />" . mysql_error() );

  echo "$user has been sent a request you must now wait for it to be accepted";
  // useful in troubleshooting the SQL statement
  

} else {
  echo "you are allready friends with this user";
} 
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/109032-stping-users-adding-themselfs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.