LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-25-2023, 10:20 AM   #1
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Rep: Reputation: Disabled
PHP Button Lable Toggle


All,

I have the following simple code:
Code:
<?php
	/**************************************************************************/
	/*   Author:   Nyle E. Davis                Create Date: 23/10/06         */
	/*   Modifier: Nyle E. Davis                Modify Date: 		  */
	/*   Run CMD:  php /3T/Scripts/Projects/accoungts.php                          */
	/*   Purpose:  This proc allows additions to the 4-2-Day DB, by the Admin */
	/*             but only displays to the non-Admin users.  All Users must  */
	/*             register to get the daily texts and devotional scriptures  */
	/*             and thoughts recorded in the DB.  the DBs used are both    */
	/*             the 42dy DB, the Pursuit of Holiness devotional and the    */
	/*             My Utmost for His Highest devotional.  Under certain       */
	/*             conditions the 2 devotional DBs may be combined.		  */
	/**************************************************************************/
	$DB1	=	"42Day";		// Declare the 4 Today DB
	$DB2	=	"POH";			// Declare the POH DB
	$DB3	=	"MyUTHigh";		// Declare the My Utmost DB
	$DOY	=	get_doy ();		// Get the Julian Date for today
	$usr	=	"";			// Declare the User ID
	$ust	=	"";			// Declare the User Type/Status
	$emo	=	get_emobj();		// Load the EM framework
	$upm	=	get_usr_perms ($ust);	// Get the User permissions
	$dsp	=	get_dsp ($usr,$ust);		// Declare the display var
	//echo "DOY => $DOY ";

	Function get_doy () {
		/******************************************************************/
		/*   Purpose:  Get and return the DOY: Day Of the Year.           */
		/******************************************************************/
		return date('z');
	}	// end function get_doy

	Function get_emobj () {
		/******************************************************************/
		/*   Purpose:  Get and load the EM framework objects.             */
		/******************************************************************/
		
	}	// end function get_emobj

	Function get_usr_perms () {
		/******************************************************************/
		/*   Purpose:  Pull the user permissions from the DB.             */
		/******************************************************************/
		
	}	// end function get_usr_perms

	Function get_dsp ($usr, $ust) {
		/******************************************************************/
		/*   Purpose:  Get the display screen values to display in HTML.  */
		/*     Parms:  $usr: the USERID & $ust: USER status/permissions.  */
		/******************************************************************/
		$dsp1	=	get_hdr ();
		$dsp2	=	$dsp1.get_tbl ($usr, $ust);
		return $dsp2;
	}	// end function get_dsp

	Function get_hdr () {
		/******************************************************************/
		/*   Purpose:  Get the display screen values to display in HTML.  */
		/*     Parms:  $usr: the USERID & $ust: USER status/permissions.  */
		/******************************************************************/
		$hdr	=	"<center><h2>Accounts/Contacts Page</h2>
				<h4>Search, Add, Manage Accounts/Contacts</h4>	
				</center>";
		return $hdr;
	}	// end function get_hdr

	Function get_tbl ($u,$t) {
		/******************************************************************/
		/*   Purpose:  Get the display screen values to display in HTML.  */
		/*     Parms:  $usr: the USERID & $ust: USER status/permissions.  */
		/******************************************************************/
		if ( (empty($u)) || (empty($t))) {
			$ls = 'checked';
			$ss = 'unchecked';
			if (isset($_POST['mode'])) {
				$selected_radio = $_POST['mode'];
				if ($selected_radio == 'login') {
					$ls = 'checked';
					$bn = 'Login';
				} else if ($selected_radio == 'signup') {
					$ss = 'checked';
					$bn = 'Sign Up';
				}	// end if else
			} else {
				$ls = 'checked';
				$bn = 'Login';
			}	// end if isset
echo $bn;
			$tbl	=	"<center><h3>Login or Sign Up!</h3></center>
					<table width='25%' align='center' border='0'>
						<tr>
							<td><INPUT TYPE='RADIO' Name ='type' 
								value= 'login' action=
								get_lab()>Login</td>
							<td><INPUT TYPE='RADIO'  Name ='type' 
								value= 'signup' action=
								get_lab()>Sign Up</td>
						</tr> 
					</table>
					<table width='45%' align='center' border='0'>
						<tr>
							<td>Enter User ID! ==></td>
							<td><INPUT TYPE='Text' size='20'></td>

						</tr> 
						<tr>
							<td>Enter Password! ==></td>
							<td><INPUT TYPE='Text' size='20'></td>
						</tr> 
					</table>
					<center><INPUT TYPE='submit' value=$bn></center>";

		} else {
			$m	=	"<center><h3>Mode</h3></center>";
			$tbl	=	$m."<center><h2>Accounts/Contacts Page</h2>
					<h4>Search, Add, Manage Accounts/Contacts</h4>	
					<h3>Mode</h3>
					</center>
					<table width='35%' align='center' border='0'>
						<tr>
							<td><INPUT TYPE='RADIO' Checked> Search</td>	
							<td><INPUT TYPE='RADIO'>Add</td>
							<td><INPUT TYPE='RADIO'>Manage</td>
						</tr> 
					</table>
					<table width='65%' align='center' border='0'>
						<tr>
							<td>Enter search term! ==></td>
							<td><INPUT TYPE='Text' size='35'></td>
							<td><INPUT TYPE='submit' value='Search'></td>
						</tr> 
					</table>";
		}	// end if empty
		return $tbl;
	}	// end function get_hdr

	Function prc_rad () {
		/******************************************************************/
		/*   Purpose:  Get the display screen values to display in HTML.  */
		/*     Parms:  $usr: the USERID & $ust: USER status/permissions.  */
		/******************************************************************/
		$rval = $_POST["type"];
		if($rval == "login") {
			$ls = 'checked';
			$bn = 'Login';
		} else if ($rval == 'signup') {
			$ss = 'checked';
			$bn = 'Sign Up';
		}	// end $rval
	}	// end function prc_rad


?>

<html>
<body>
	<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
	<?php echo $dsp; ?>

	</form>
</body>
</html>
You'll see in the get_tbl function I correctly toggle the selected 'RADIO' buttons, but the $bn (Button Name) does not change and must for the processing function is looking for the Name of the SUBMIT button where:
  1. Sign Up: Will add the user to the User table in the DB,
  2. Login: Will query the user table for the registered user,
Somehow I'm not getting this done, which cqn still be done in the PHP codeing section, which I've done before but forgnotten how. I think the "toggle action" has to chnge to call a function, but did this probably 15-20 years back, so need help. None on the published HOWTOs gve me the right answer, and I tried 5. The only one that worked used javascript which I do not want to use.

All help appreciated.

Cheers!

TBNK
 
Old 10-25-2023, 04:10 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
Code:
<td><INPUT TYPE='RADIO' Checked> Search</td>	
<td><INPUT TYPE='RADIO'>Add</td>
<td><INPUT TYPE='RADIO'>Manage</td>
Bad syntax. You have not defined a group, value or id.
Code:
<input type = "radio" name = "radio" value = "Search" id = "radio1" checked> Search </input>
<input type = "radio" name = "radio" value = "Add" id = "radio2" > Add </input>
<input type = "radio" name = "radio" value = "Manage" id = "radio3"> Manage </input>
And you could not find any examples?

Last edited by michaelk; 10-25-2023 at 04:13 PM.
 
Old 11-02-2023, 10:09 AM   #3
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Code:
<td><INPUT TYPE='RADIO' Checked> Search</td>	
<td><INPUT TYPE='RADIO'>Add</td>
<td><INPUT TYPE='RADIO'>Manage</td>
Bad syntax. You have not defined a group, value or id.
Code:
<input type = "radio" name = "radio" value = "Search" id = "radio1" checked> Search </input>
<input type = "radio" name = "radio" value = "Add" id = "radio2" > Add </input>
<input type = "radio" name = "radio" value = "Manage" id = "radio3"> Manage </input>
And you could not find any examples?
michaelk,

Working on it but time is limited!

Cheers!

TBNK
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Acer laptop trackpad toggle button makes mouse freeze until restart (Linux Mint and Lubuntu) THX1138b Linux - Hardware 3 10-23-2017 11:40 AM
HP WiFi toggle button not working bogdanc2011 Linux - Laptop and Netbook 3 12-24-2013 10:40 AM
touchpad scroll button continuous scrolling toggle ldmn Linux - Laptop and Netbook 2 05-30-2013 02:01 AM
Python GTK click and toggle button? nutjob16 Programming 1 11-29-2012 02:08 AM
GTK toggle button to pixmap verigoth Programming 1 07-22-2002 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration