Jump to content

Allow Users To Edit Database Info


xxnwoxx

Recommended Posts

Sir/ma'am,

 

With the script I'm using to run my website, I've been trying to add an additional feature for the users to add/edit. I'll try to provide as much info as I can, hopefully it'll help.

 

Here is the code I'm using to display the user's unique info from the db.

<a class="wallet-edit"><?php echo $_SESSION['simple_auth']['INFO']?></a>

That displays the user's info from the column 'INFO' perfectly. It's also a js popup to a menu to where I'm hoping to add a single textbox to edit the INFO.

 

The script uses a similar function to edit the password with a popup. I've tried modifying the code to edit the INFO column but it doesn't work. Here is the default code it has to edit the password. I'm not sure if it can be changed to edit another column or needs a new piece of code for that.

// user edit
 	$('body').on('click', '.username-edit', function() {

    	$('#modal').html(' ');

 		var output = '<div class="modal-content"><h5><?php echo lang::get("Change password")?></h5><hr />';
 		output += '<h5><?php echo lang::get("New password:")?></h5><input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />';
 		output += '<h5><?php echo lang::get("Confirm password:")?></h5><input type="password" name="password2" id="password2" value="" class="text ui-widget-content ui-corner-all" />';

 		output += '</div>';

 		output += '<div class="modal-buttons right">';
 		output += '<button id="confirm-button" type="button" class="nice radius button"><?php echo lang::get("Change")?></button>';
 		
		output += '</div>';
 		
 		output += '<a class="close-reveal-modal"></a>';
 		
 		$('#modal').append(output);
 		$('#second_modal').hide();
 		$('#modal').reveal();

 		$('#confirm-button').click(function(){

 			$('#password').css('border-color', '#CCCCCC');
 			$('#password2').css('border-color', '#CCCCCC');
 			
			var password = $('#password').val();
			var password2 = $('#password2').val();

			if(typeof(password) === 'undefined' || password == ''){
				$('#password').css('border-color', 'red');
				return false;
			}
			
			if(password != password2){
				$('#password2').css('border-color', 'red');
				return false;				
			}

			password_data = encodeURIComponent(password);
			
			$.post("<?php echo gatorconf::get('base_url')?>", { changepassword: password_data} ).done(function(data) {
				// flush 
				window.location.href = '<?php echo gatorconf::get('base_url')?>';
			});
			


	    });

    });

If the code above can be edited to work with what I'm trying to do, it of course only needs one textbox and doesn't have to be confirmed by a second input.

 

 

 

Please help! Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.