[請益] post被連續觸發了兩次
各位前輩大家好
小弟最近用laravel做寄發認證信的時候
發現同一個post會同時被觸發兩次
所以導致使用者會一次收到兩封認證信
以前寫都覺得沒關係 只要有寄出就好
可是現在覺得這樣很容易造成問題
所以來請教各位前輩 該如何解決
--------以下為簡略程式碼-----------
controller :
class Forget extends BaseController{
public function forget(){
$input = Input::all();
$user = User::where('account',$input['account'])->get()->first();
if($user->count()){
//產生token 存進database
Mail::send('reminder',array('url'=>'www.example.com','name'=>$user->name),
function($message) use ($user){
$message->from('ql4au04@example.com','ql4au04');
$message->to($user->email,$user->name)->subject('reminder');
});
return Redirect::to('/');
}else{
return Redirect::to('/')->withErrors();
}
}
}
router:
Route::get('/','User@index');
Route::post('/forget',array('as'=>'forget','uses'=>'forget@forget'));
--
Sent from my CASIO fx-991es .
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.142.3.25
※ 文章網址: http://www.ptt.cc/bbs/PHP/M.1409950193.A.3B8.html
推
09/06 09:02, , 1F
09/06 09:02, 1F
→
09/06 09:20, , 2F
09/06 09:20, 2F
ptt 的界面vim太像 不小心就用了...
用vim也沒比較強 還不是一直有問題XD
目前解決了 感覺是我命名的方式有問題
把 public function forget 改成 public function remind
就不會同時被觸發兩次了 這是我目前的猜測和解決辦法
不知道是不是還有潛藏其他問題
※ 編輯: ql4au04 (223.142.34.31), 09/06/2014 14:38:56
→
09/07 00:12, , 3F
09/07 00:12, 3F
→
09/07 00:42, , 4F
09/07 00:42, 4F
→
09/07 01:33, , 5F
09/07 01:33, 5F
→
09/07 01:34, , 6F
09/07 01:34, 6F
我php的版本是5.5.3 測試的結果是 如果有construct 則同名函式不會有問題
可是如果沒有 同名函式一樣會被視為construct誒
※ 編輯: ql4au04 (223.142.114.155), 09/08/2014 03:22:20
→
09/08 16:42, , 7F
09/08 16:42, 7F
→
09/08 16:42, , 8F
09/08 16:42, 8F
推
09/08 20:23, , 9F
09/08 20:23, 9F
→
09/08 20:24, , 10F
09/08 20:24, 10F
→
09/17 22:49, , 11F
09/17 22:49, 11F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章