You have multiple routes leading to the same controller methods. Is there a reason for that?
You also have a Route::any before a Route::post for the same URI. That's an issue because I think for these two routes - 'dnslookup' and 'hostlookup' - it will never trigger the post route because it'll always be triggered by the any route.
Hey Thanks for the Reply, I am currenly accessing fist two routes and secondly on my local system, development machine. its working fine
Route::get('hostname', 'DNSController@index');
Route::post('hostname', 'DNSController@lookup');
If you dd()
your results, what do you get?
public function lookup(HostnameRequest $request)
{
$hostlookup = $request->input('hostlookup');
dd($hostlookup);
$hostname = gethostbyaddr($hostlookup);
return view('hostname')->with('hostname', $hostname);
}
It shows nothing, I think its not checking
Route::post('hostname', 'DNSController@lookup');
Are you accessing the route through a form? If so, can you post that code?
Well, When I Access this Route, it just take me to the form page
Route::get('hostname', 'DNSController@index');
When I Lookup an IP Address and Hit Enter, it should take me to this Route,
Route::post('hostname', 'DNSController@lookup');
here is the form code,
<form name="user_form" id="dnslookup" action="{{ url() }}/hostname" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="row center-block">
<div class="col-lg-6 center-block">
<div class="input-group">
<input type="text" id="hostlookup" name="hostlookup" value="" class="form-control" placeholder="Search for Address" required>
<span class="input-group-btn">
<button class="btn btn-default" type="hostsubmit">Lookup</button>
</span>
</div>
</div>
</div>
</form>
I can see these routes in the list,
POST | hostname | | App\Http\Controllers\DNSController@lookup | guest |
| | GET|HEAD | hostname | | App\Http\Controllers\DNSController@index | guest |
Are you logged in by any chance since it has the guest middleware applied to it?
I am using middleware just only, still no logged in function or module created and just for the sack of testing, I have just removed this but still no success on live website
Hm...everything looks okay, although I would change your button. It should be type="submit".
<button class="btn btn-default" type="submit">Lookup</button>
Also, make sure that in your request file, authorize is set to true.
Edit: Also, if you dd()
inside the request file, does it trigger?
Ahh ! Well there was a silly mistake , I was missing lookup name in form.
Lol. Okay. :) That happens to all of us.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community