I have two applications one in normal Php and other in Yii
I am posting a form from first application to second
It is successfully reaching the controller but I dont know how to gather or collect all attributes…I can collect each attribute separately by using the request function…but I dont know how to regather all of them and save it.
<form name="regform" method="post" action="<? echo "REQUIRED URL/createuser"; ?>
<input id="Fusername" name="req_username" size="20" type="text" value="<?=$req_username?>">
<input id="Fpassword" name="req_password" size="20" type="password" value="<?=$req_password?>">
Following is my Yii apllication and I want to save data in table "user"
public function actionCreateuser()
{
$username = $_REQUEST['req_username'];
echo $username;
$model=new user;
$model->attributes=<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />???;
if($model->save())
echo "success";
}
andy_s
(Arekandrei)
January 14, 2010, 10:10am
2
I think the scheme should look like:
<form name="regform" method="post" action="<? echo "REQUIRED URL/createuser"; ?>
<input id="Fusername" name="User[username]" size="20" type="text" value="<?=$req_username?>">
<input id="Fpassword" name="User[password]" size="20" type="password" value="<?=$req_password?>">
public function actionCreateuser()
$model=new User;
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
{
echo 'success';
}
}
}
Model User must have attributes username and password, and also they must be declared as safe .
andy_s:
I think the scheme should look like:
<form name="regform" method="post" action="<? echo "REQUIRED URL/createuser"; ?>
<input id="Fusername" name="User[username]" size="20" type="text" value="<?=$req_username?>">
<input id="Fpassword" name="User[password]" size="20" type="password" value="<?=$req_password?>">
Model User must have attributes username and password, and also they must be declared as safe .
Ya the model user is having those attributes but we cant change the name of required attributes according to the table.
If we want to save the same data in other table also then??? so i think User[username] wont work…