Unique names =)

Forum
Last Post
Threads / Messages

kristhasirah

Member
Member
Joined
Jan 22, 2010
Messages
197
Points
16
Location
In middle of the nothingness
Mysidian Dollar
20,995
this is just a copy/paste edit code of the create a shop code but it works for that ^^
at the very end of your myadopts.php page before the } ?> paste this:
PHP:
     	    private function dataValidate(){
	    $mysidia = Registry::get("mysidia");
		if(!$mysidia->input->post("adoptname")) throw new BlankFieldException("You did not enter in a name for this creature. Please <a href='/myadopts/rename/{$this->adopt->getAdoptID()}'>go back</a> and try again.");		
		$name = $mysidia->db->select("owned_adoptables", array(), "name = '{$mysidia->input->post("adoptname")}'")->fetchObject();
		if($this->action == "rename" and is_object($name)) throw new DuplicateIDException("A creature with the same name already exists, please <a href='/myadopts/rename/{$this->adopt->getAdoptID()}'>go back</a> and change its name.");
		return TRUE;
	}

then look for public function rename and add:
PHP:
		    $this->dataValidate();
after the
PHP:
		if($mysidia->input->post("submit")){
this don't affect the named adopts in the main adopt page, unless you add it there... i haven't tested this code in there... im using kittyas code to name the adopt after the creature is adopted so when the user gives the adopt a name is redirected to the rename page in the myadopts. so i don't need to add it to the main page..
This also throws an error, when the user tries to remove the name of the adopt and leave it blank, so no more blank names ^^
If you only want the blank name error then just remove or comment out the $name and the second if($this->action lines.
again if i dint make sense this is how the code should look:
PHP:
     	    private function dataValidate(){
	    $mysidia = Registry::get("mysidia");
		if(!$mysidia->input->post("adoptname")) throw new BlankFieldException("You did not enter in a name for this creature. Please <a href='/myadopts/rename/{$this->adopt->getAdoptID()}'>go back</a> and try again.");		
		return TRUE;
	}

hope someone finds this useful ^^

edit:
ok here is the code for the adopt.php page:
PHP:
	     	    private function dataValidate(){
	    $mysidia = Registry::get("mysidia");
		if(!$mysidia->input->post("name")) throw new BlankFieldException("You did not enter in a name for this creature. Please go back and try again.");		
		$name = $mysidia->db->select("owned_adoptables", array(), "name = '{$mysidia->input->post("name")}'")->fetchObject();
		if($this->action == "index" and is_object($name)) throw new DuplicateIDException("A creature with the same name already exists, please go back and change its name.");
		return TRUE;
	}
then in public function index and add:
PHP:
		    $this->dataValidate();
after the
PHP:
		if($mysidia->input->post("submit")){
WARNING! this code is for an unedited adopt page! if you are using the random code i posted it will be kind of annoying to the users to have to return to the main page and see that the eggs have changed and they have lost the rare/ultrarare egg ^^ unless you know how to code something similar to dragon cave name box that tells you if the name is in use.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top