mercredi 27 novembre 2019

Can't get into referring page in Laravel 5.3

I don't know if this question might have a duplicate but I can't find any solution. I am new to laravel and I used version 5.3 and PHP 5.6.4, I have a hard time saving my data into mysql database with php form with action="addFriend" the problem is it can't get into the referring page. This is my code in friend_add.blade.php

        <form method = "post" action = "/addFriend">
        
            <table>
                <tr>
                    <td>Friend ID</td>
                    <td><input type='text' name='friend_id' /></td>
                <tr>
                    <td>Friend Name</td>
                    <td><input type="text" name='friend_name'/></td>
                </tr>
                <tr>
                    <td>Place</td>
                    <td><input type="text" name='place'/></td>
                </tr>
                <tr>
                    <td colspan = '1'>
                        <button type="submit" class="btn btn-primary">Submit</button>
                    </td>
                </tr>
            </table>
        </form>

web.php

Route::post('/addFriend','FriendController@post');

and this is my code in FriendController.php

  {
    $friend_id = $request->input('friend_id');
    $friend_name = $request->input('friend_name');
    $place = $request->input('place');
    $data=array('FriendID'=>$friend_id,"FriendName"=>$friend_name,"Place"=>$place);
    DB::table('friend')->insert($data);
    echo "Record inserted successfully.<br/>";

  }

The localhost will return No Object Found. Can anyone help me? Thanks. It will mean a lot.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire