show it is registered and it exists

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
saleh
User
Posts: 470

show it is registered and it exists

Post by saleh »

hello

If a new usres is already present

If it is registered and it exists I need a message to show it

The message will be in Username and full name

I mean, if he wants to add a record and an existing message appears to him

The message will be in ID_NO and full name


mobhar
User
Posts: 11660

Post by mobhar »

You may simply use "Row_Inserting" server event to add your validation code.

Just write SQL Select inside the ew_ExecuteScalar global function to check the record whether existed in your "users" table, and if that global function meets your criteria, then return FALSE, and display the failure message that informs user already exists.

For more info and example, please read "Some Global Functions" sub-topic at the bottom of "Server Events and Client Scripts" topic from PHPMaker Help menu.


saleh
User
Posts: 470

Post by saleh »

hello

Possible code please
If the table is:
table: users
And the fields I wish to reveal in the letter
Field : ID_NO
Field : Name

Thanks for help


kirondedshem
User
Posts: 642

Post by kirondedshem »

The code would lokk like this

Go to users table->select server events & client scripts-> select table specfic-> select row_inserting and paste the code

// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE

//check if ID_NO is taken already
//ASSUMING ID_NO is name of the field
$id_no_taken = ExecuteScalar("select count(*) from users where ID_NO = '".$rsnew["ID_NO"]."'"); 
    //check if the name entered had already been used
$Name_taken = ExecuteScalar("select count(*) from users where Name = '".$rsnew["Name"]."'"); 


if($id_no_taken >= 1){
	$this->CancelMessage = "The ID_NO ".$rsnew["ID_NO"]." is already taken";
	return FALSE;                
}
elseif($Name_taken >= 1){
	$this->CancelMessage = "The Name ".$rsnew["Name"]." is already taken";
	return FALSE;                
}
else{                                            

	return TRUE;
}

}

Please study it well so you can modify it to work for you better.
Also please get some books on php so you can learn some basic concepts to help you visualise implimentations and approcahes to problems using php
ALso refer to the help menu for more iformation and examples on this event as well as what it means


Post Reply