Jump to content

Blocking Charcters


whiteboikyle

Recommended Posts

seems not to be working for my function

 

 

	
<?php
function add_clan(){
global $config;

	$editor = $_POST['editor'];
	$body = $_POST['body'];
	$URL = $_POST['url'];
	$name = $_POST['name'];
	$date = time();
	//restricts >< = ; \/
	if (preg_match('%["\'<>/]%', $name)) {
		session_register(short);
		$_SESSION['short'] =
		"body contained a charcter that was invalid!<br />
		you cant use ><=;/\ as a charcter!";
		header("location: view.php?function=addclan");		
	}
	if (preg_match('%["\'<>/]%', $body)) {
		session_register(short);
		$_SESSION['short'] =
		"name contained a charcter that was invalid!<br />
		you cant use ><=;/\ as a charcter!";
		header("location: view.php?function=addclan");		
	}
		if (get_magic_quotes_gpc()) {
			$editor = stripslashes($editor);
			$body = stripslashes($body);
			$URL = stripslashes($URL);
			$name = stripslashes($name);
		}

	$editor = mysql_real_escape_string($editor);
	$body = mysql_real_escape_string($body);
	$URL = mysql_real_escape_string($URL);
	$name = mysql_real_escape_string($name);

	$query = $config->query("SELECT * FROM clans WHERE name='".$name."'");
	$count=mysql_num_rows($query);	
	$query1 = $config->query("SELECT * FROM clans WHERE URL='".$URL."'");
	$count1=mysql_num_rows($query1);	


	if(strlen($name) < "1" or strlen($name) > "25"){
		session_register(short);
		$_SESSION['short'] =
		"Name '$name' was to short or to long! It must be greater then 5 charcters long and shorter then 25!";
		header("location: view.php?function=addclan");
	}
	elseif($count===1 or $count > 1){
		session_register(short);
		$_SESSION['short'] = "The clan name you chose is already in use! Please choose another name!";
		header("location: view.php?function=addclan");	
	}
	elseif($count1===1 or $count1 > 1){
		session_register(short);
		$_SESSION['short'] = "The clan URL you chose is already in use!";
		header("location: view.php?function=addclan");			
	}
	elseif(strlen($URL) < "15" or strlen($URL) > "255"){
		session_register(short);
		$_SESSION['short'] =
		"URL '$URL' was to short or to long!! It must be greater then 14 and shorter then 255 charcter long!";
		header("location: view.php?function=addclan");	
	}
	elseif(strlen($body) < "50"){
		session_register(short);
		$_SESSION['short'] =
		"Body '$body' was to short! it must be greater then 50 charcter long!";
		header("location: view.php?function=addclan");				
	}
	else{				
		$query = "INSERT INTO clans (ID, name, body, date, ranking, URL, editor) VALUES (NULL, '$name', '$body', '$date', '1', '$URL', '$editor')";
		$result = $config->query($query);
		session_register(add_clan);
		$_SESSION['complete'] =
		"Clan $name has been added to our database! It will start out with a ranking of 1.<br />
		Please give this 'link to come' direct link to your members to vote for! <br />
		You are limited 1 vote per day per IP!<br />
		<a href='main.php'>Countinue</a>";
		header("location: view.php?function=addclan");		
	}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/111548-blocking-charcters/#findComment-572638
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.