Help! Access Require to edit the database data

Guys can you help me how to change the data in the database using yii?

Currently i tried but it’s need permission.Attachment 6986 not found.


<h3>Update Data Produk</h3>


<form action="" method="post" id="myForm">

			<input type="hidden" id="id"

			value="<?php echo $dataProduk->id_produk;?>" />

			<table>

			<tr>

			<td>Nama Produk</td>

			<td>:</td>

			<td><input type="text" value="<?php echo $dataProduk->nama_produk;?>" name="nameproduk" size="50" />

			</td>

			</tr>

			<tr>

			<td>Jumlah Produk</td>

			<td>:</td>

			<td><input type="text" value="<?php echo $dataProduk->jumlah_produk;?>" name="jumlahproduk" size="5" />

			</td>

			</tr>

			<tr>

			<td>Harga Produk</td>

			<td>:</td>

			<td><input type="text" value="<?php echo $dataProduk->harga_produk;?>" name="hargaproduk" size="25" />

			</td>

			</tr>

			<tr>

			<td>&nbsp;</td>

			<td>&nbsp;</td>

			<td><input id="save" type="button" value="Update" /></td>

			</tr>

			</table>

</form>


<script>

$(document).ready(function(){

		$('#save').click(function(){

						var id = $('#id').val();

						$('#save').attr({

										value : 'loading..' ,

										disable : true,

						});


						var myFormData = $("myForm").serialize();


				$.ajax({

						type:'POST',


						url:'<php echo Yii::app()->request->baseUrl;?>/ajax/update/'+id,


						data:myFormData,


										success:function(data){

						$('#data').load('<?php echo Yii::app()->request

							->baseUrl;?>/ajax/indexproduk');

													$('#save').attr({

																	value : 'Update',

																	disable : false,

													});


						$("#form").load('<?php echo Yii::app()->request->baseUrl;?>/ajax/create');

										}

						});

						return false;

		});

});


</script>

This is mine main.php


<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		/*

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'Enter Your Password Here',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

		*/

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		// uncomment the following to enable URLs in path-format

		

		'urlManager'=>array(

			'urlFormat'=>'path',

			'showScriptName'=>false,

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

		

		// uncomment the following to use a MySQL database

		

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=yiinigo',

			'emulatePrepare' => true,

			'tablePrefix' => '',

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

		

		'errorHandler'=>array(

			// use 'site/error' action to display errors

			'errorAction'=>'site/error',

		),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);

It’s showing error message

You forgot the question mark <?php in this line

url:’<?php echo Yii::app()->request->baseUrl;?>/ajax/update/’+id,

Oh thanks oligalma, mine mistake.

Welcome!

Another thing I’ve seen is that you could use the createUrl method in this line:


 url:'<?php echo Yii::app()->createUrl('ajax/update') ?>/' + id, 

http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail