Direct access from the main menu to a record if existed

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
tchristophe
Posts: 6
Joined: 2019-10-22 14:13

Direct access from the main menu to a record if existed

Post by tchristophe » 2019-10-22 16:00

Hi everyone,

I have a table 'adherents' with a single record possible for a user.
If the record do not exist, the view of the table is empty and it's possible to complete the form and save it.
If a record still exited I want the user directly connect to the single record (he can modify and save the informations in the form)...
I need to verify if a record exist or not to drive the user in the good case when he click on button from the main menu.
I have tried the code below but I dont know how use 'set_record_owner'...

Code: Select all

$email = $memberInfo['email'];
$resultat = sqlValue("SELECT ads_adherents.courriel FROM ads_adherents WHERE ads_adherents.courriel = '$email'");
*if($resultat !== ''){	
	set_record_owner("Adherents", $email, $courriel);
	}
	else
	{
	}	
Any information on the 'set_record_owner' function is welcome !
Thank for your help, ideas, etc.
Chrsitophe

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Direct access from the main menu to a record if existed

Post by pbottcher » 2019-10-22 19:04

Hi,

the usage is:

set_record_owner($tn, $pk, $user) -- Set/update the owner of given record

where $tn is your tablename, $pk the primary key of that table, $user the username to set as owner
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

tchristophe
Posts: 6
Joined: 2019-10-22 14:13

Re: Direct access from the main menu to a record if existed

Post by tchristophe » 2019-10-23 09:57

Hi pböttcher,

I try this way...
Thank you very mutch
Christophe

tchristophe
Posts: 6
Joined: 2019-10-22 14:13

Re: Direct access from the main menu to a record if existed

Post by tchristophe » 2019-10-23 16:19

Hi everyone,

In fact, I want to call the single record of the user in the table ' adherents' from the home page button link with the 'ads_adherents.idAdherent' number key... ( hope I'm understandinable...) :?:

Code: Select all

$email = $memberInfo['email']; // Only one possible
$selectedID = sqlValue("SELECT ads_adherents.idAdherent FROM ads_adherents WHERE ads_adherents.courriel = '$email'");
if($selectedID > 0){

		// How can I config my URL here to call the single record view ?
		
		=> http://localhost/busistone/ads_adherents_view.php?SelectedID=$selectedID
				
		}	
Thank gain for your help, ideas, suggestions, etc.
Regards
Christophe

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Direct access from the main menu to a record if existed

Post by pbottcher » 2019-10-23 19:27

Hi,

use

redirect($url);

where $url is your url

$url='http://localhost/busistone/ads_adherent ... selectedID
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

tchristophe
Posts: 6
Joined: 2019-10-22 14:13

Re: Direct access from the main menu to a record if existed

Post by tchristophe » 2019-10-24 09:10

Thank again pböttcher !

tchristophe
Posts: 6
Joined: 2019-10-22 14:13

Re: Direct access from the main menu to a record if existed

Post by tchristophe » 2019-10-24 15:29

Humm,

I've insert the code below...

Code: Select all

// Redirection sur enregistrement en page wiew si existant
			if($selected_ID > 0){				
				$URL = 'ads_adherents_view.php?SelectedID=$selected_ID';
				redirect($URL);
			}
And I receive the answer "ERR_TOO_MANY_REDIRECTS" from the serveur (Wamp)
Any Idea ?

Thank you
Christophe

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Direct access from the main menu to a record if existed

Post by pbottcher » 2019-10-24 16:46

Hi,

well, you check if there is a record and if there is one, you redirect to the page with the record.
When reaching the page, you check if there is a record and if there is one, you redirect to the page with the record.

This results in the looping redirects.

You need to catch that situation to understand from where the page was called (or what parameters are in the url).
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply