Token Value

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

Token Value

Post by ethanlazarus »

I am upgrading my files from phpmaker 2018 to 2024. This has been quite the project! In 2018, if I wanted to submit a custom form, I had to use the token_val. Do I need to submit a token for custom forms in 2024? The tokenval field no longer works. Thanks!

Example custom form:

 $currenturl = $_SERVER["REQUEST_URI"];
		 $tokenname = TOKEN_NAME;
		 GLOBAL $class_schedule_list;
		 $tokenval = $class_schedule_list->Token;
	        $showcalbutton = '
		 <form action="'.$_SERVER['PHP_SELF'].'" method="post">
		<input type="hidden" name="SubmitCheck" value="sent">
		<input type="hidden" name="showcal" value = 1>
		<input type="hidden" name="'.$tokenname.'" value="'.$tokenval.'">
		<button type="submit" class="btn btn-sm btn-primary">
		<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span> Show Calendar</button>	
	   </form>';
		 $hidecalbutton = '
		  <form action="'.$_SERVER['PHP_SELF'].'" method="post">
		<input type="hidden" name="SubmitCheck" value="sent">
		<input type="hidden" name="showcal" value = 0>
		<input type="hidden" name="'.$tokenname.'" value="'.$tokenval.'">
		<button type="submit" class="btn btn-sm btn-primary">
		<span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span> Hide Calendar</button>	
	   </form>';

mobhar
User
Posts: 11470

Post by mobhar »

For v2024, you may refer to this documentation.


ethanlazarus
User
Posts: 16

Post by ethanlazarus »

Thank you - I see the new code, but how do I define $TokenNameKey and $TokenValueKey? I previously defined with $tokenname = TOKEN_NAME; - what do I use in 2024? Thanks so much!


mobhar
User
Posts: 11470

Post by mobhar »

It is already defined in src/config.php file, so you don't have to define it by yourself.

As long as you have already enabled Check token for form post option under Tools -> Advanced Settings of your PHPMaker project, then you just need to add that code from the documentation link above to your Custom Form.


Post Reply