Jump to content

sadboys

Members
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

About sadboys

  • Rank
    Member
  1. Updated Code: public function actionLogin() { if (!Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', [ 'model' => $model, ]); } } I tried using the default user table and it works perfectly fine. However if I use my own user table with the other additional columns it doesn't work.
  2. Hello, I'm currently using Yii2 Framework in developing my project. I encounter an error that whenever I try to login it always says "Incorrect Username or Password" even though my password is correct. I checked the user table in phpmyadmin and the password is getting hashed and there's no problem since the user information is stored in the user table without problems but if I try to login it doesn't accept the username or password. Anyone encounter a similar issue like mine? Here's the SignupForm.php class SignupForm extends Model { public $username; public $email; public $password; public $first_name; public $middle_name; public $last_name; public $contact; public $birth_date; public $type; public $external_type; public $status; public $region_id; public $barangay_id; public $province_id; public $city_municipal_id; /** * @inheritdoc */ public function rules() { return [ ['username', 'trim'], ['username', 'required'], ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], ['username', 'string', 'min' => 2, 'max' => 255], ['email', 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'string', 'max' => 255], ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'], ['password', 'required'], ['password', 'string', 'min' => 6], ['first_name', 'required'], ['first_name', 'string', 'max' => 45], ['middle_name', 'string', 'max' => 45], ['last_name', 'required'], ['last_name', 'string', 'max' => 45], ['contact', 'required'], ['contact', 'string', 'max' => 11], ['birth_date', 'required'], ['type', 'required'], ['type', 'string', 'max' => 45], ['external_type', 'string', 'max' => 45], ['status', 'string', 'max' => 45], ['region_id', 'required'], ['barangay_id', 'required'], ['province_id', 'required'], ['city_municipal_id', 'required'], ]; } /** * Signs user up. * * @return User|null the saved model or null if saving fails */ public function signup() { if (!$this->validate()) { return null; } $user = new User(); $user->username = $this->username; $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); $user->first_name = $this->first_name; $user->middle_name = $this->middle_name; $user->last_name = $this->last_name; $user->contact = $this->contact; $user->birth_date = $this->birth_date; $user->type = $this->type; $user->external_type = $this->external_type; $user->status = $this->status; $user->region_id = $this->region_id; $user->barangay_id = $this->barangay_id; $user->province_id = $this->province_id; $user->city_municipal_id = $this->city_municipal_id; return $user->save() ? $user : null; } function login public function login() { if ($this->validate()) { return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); } else { return false; } } function signup public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } return $this->render('signup', [ 'model' => $model, ]); }
  3. Hello, I'm currently learning Google Maps API, I created a page that shows the Google Maps with custom markers. My problem is that the Google Maps works fine but the custom markers that I set does not work. Here's what I did. script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBSTRDm6eRdkpoVOB2VJVJgTCNgmcuDcq0&callback=initMap"> </script> <script> function initmap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 16, center: new google.maps.LatLng(14.529133, 121.021747), mapTypeId: 'roadmap' }); var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/'; var testIcon = 'http://maps.google.com/mapfiles/kml/paddle/'; var icons = { evac: { icon: iconBase + 'ranger_station.png' }, warehouse: { icon: iconBase + 'truck.png' } }; var features = [ { position: new google.maps.LatLng(14.529133, 121.021747), type: 'evac' } ]; features.forEach(function(feature) { var marker = new google.maps.Marker({ position: feature.position, icon: icons[feature.type].icon, map: map }); }); } </script> </head> <body onload="initmap()"> </body> <div id="map_canvas" style="width: 1100px; height: 1000px"></div> I'm using the KML map files right now but it does not work, where did I get wrong here?
  4. Yeah, in my db the default value is already "CURRENT_TIMESTAMP", but I want the time to be displayed on the form so what I did was like that. Thank you anyways
  5. I've already read that before but I thought I can also use the format of timestamp in mysql, I'm currently using "y-m-d h:i:s"
  6. Isn't this the proper format for timestamp - YYYY-MM-DD HH:MI:SS ?
  7. Hello, I need a little help here. I'm using Yii2 Framework In my TicketController, I have a function that if you create a ticket it will automatically get the system time. In time_start I used TIMESTAMP TicketController.php actionCreate $model->time_start = date('YYYY-MM-DD HH:MI:SS'); In the form it does not show the proper result Also in the view after the ticket is created it shows like this
  8. I don't get it can you explain to me? :/ Nevermind I get it now, the time_end supposed to be "On Update" Thank you for giving me an idea on how to fix it, I guess I still need to improve my sql skills thank you!
  9. I did some var dumps and still when I update it still updates and gets the current date and time. In actionCreate When I create something it gets the current date and time and it fills the $model->time_start = date('y-m-d h:i:s'); In order to fill in the time_end I need to update what I have created first which was in actionUpdate I added this $model->time_start = date('y-m-d h:i:s');
  10. Hi everyone! In my Ticket _form.php. When I create ticket it gets the current time and fills in the time_start field automatically, in order to fill in the field time_end I need to update the ticket which also gets the current time when you update it. My problem is when I update it the time_start also updates and now they have the same value which supposed to be different. I have this in my form: <?= $form->field($model, 'time_start')->textInput(['readOnly' => true]) ?> <?= $form->field($model, 'time_end')->textInput(['readOnly' => true]) ?> Which automatically gets the current time of the system In my TicketController.php public function actionCreate() { $model = new Ticket(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $model->time_start = date('y-m-d h:i:s'); return $this->render('create', [ 'model' => $model, ]); } } /** * Updates an existing Ticket model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $model->time_end = date('y-m-d h:i:s'); return $this->render('update', [ 'model' => $model, ]); } }
  11. Hi everyone! In my Ticket _form.php. When I create ticket it gets the current time and fills in the time_start field automatically, in order to fill in the field time_end I need to update the ticket which also gets the current time when you update it. My problem is when I update it the time_start also updates and now they have the same value which supposed to be different. I have this in my form: <?= $form->field($model, 'time_start')->textInput(['readOnly' => true]) ?> <?= $form->field($model, 'time_end')->textInput(['readOnly' => true]) ?> Which automatically gets the current time of the system In my TicketController.php public function actionCreate() { $model = new Ticket(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $model->time_start = date('y-m-d h:i:s'); return $this->render('create', [ 'model' => $model, ]); } } /** * Updates an existing Ticket model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $model->time_end = date('y-m-d h:i:s'); return $this->render('update', [ 'model' => $model, ]); } }
×
×
  • 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.