Return to Snippet

Revision: 39559
at January 18, 2011 08:15 by shinokada


Initial Code
function pages_setup_name($id,$pid){
$name=trim($_REQUEST['name']);
if(dbOne('select id from pages where
name="'.addslashes($name).'" and parent='.$pid.'
and id!='.$id,'id')){
$i=2;
while(dbOne('select id from pages where
name="'.addslashes($name.$i).'" and parent='.$pid.'
and id!='.$id,'id'))$i++;
echo '<em>A page named "'.htmlspecialchars($name).'"
already exists. Page name amended to "'
.htmlspecialchars($name.$i).'".</em>';
$name=$name.$i;
}
return $name;
}

Initial URL

                                

Initial Description
a function which tests the submitted page name. If that name is the
same as another page which has the same parent, then a number is added to the end
and a message is shown explaining this.

Initial Title
checking the same name in db and if there is add 2 etc at the end

Initial Tags

                                

Initial Language
PHP