Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have 4 types of users in my system. So i have to include header files using conditions.
I tried below code.
if($this->session->userdata('email_admin')){
include('header_admin.php');
}
if($this->session->userdata('email_zone_manager')){
include('header_zone_manager.php');
}
if($this->session->userdata('email_state_manager')){
include('header_state_manager.php');
}
if($this->session->userdata('email_user')){
include('header_user.php');
}
When i tried with echo something and exit() its working means condition works file but header css and js etc. are not including.
if($this->session->userdata('email_admin'))
{
echo "Admin";
include('header_admin.php');
}
Above code echo "Admin" but header_admin's contents are not including.
You can load views like this...
if(isset($this->session->userdata('email_admin'))){
$this->load->view('header_admin');
}
if(isset($this->session->userdata('email_zone_manager'))){
$this->load->view('header_zone_manager');
}
if(isset($this->session->userdata('email_state_manager'))){
$this->load->view('header_state_manager');
}
if(isset($this->session->userdata('email_user'))){
$this->load->view('email_user');
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
That is my way to check file image uploaded or not , send from view to controller php laravel
$dataImages=$request->images;
if($dataImages[0] == ""){
print_r("file null");
}else{
print_r("file not null");
$pathImage='product_images/1/image-1651261589260.jpg';
if(File::exists($pathImage)){
File::delete($pathImage);
}
}
Laravel has a helper function in the request object fo that case called hasFile
if($request->hasFile('images')){
// true
} else {
// false
}
for more info check the Retrieving Uploaded Files
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
How to get the current URL without the first part dynamically?
For example:
www.google.com/en/second => /second
www.google.com/en/second/third => /second/third
Where to put the function or how to implement this in the current blade view?
You can use Request::segments:
implode('/', array_slice(request()->segments(), 1));
All http link:
$link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; // www.google.com/en/second/third
Just requested link:
$requested_link = "$_SERVER[REQUEST_URI]"; // en/second/third
If you do not want any part of link, replace it with "":
str_replace("en/", "", $requested_link); // second/third
You can put this code anywhere in view or controller. For example in view:
<?php
function get_url(){
$requested_link = "$_SERVER[REQUEST_URI]";
return str_replace("en/", "", $requested_link);
}
?>
Get the current URL including the query string...
echo url()->full();
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need write some code in Silex. I have template, witch tell user when route doesn't exist. How do it in Silex? Maybe somebody faced with it?
If I understood you correctly, you can show a 404 page to your users when the route is not found, like so:
use Symfony\Component\HttpFoundation\Response;
$app->error(function (\Exception $e, $code) {
switch ($code) {
case 404:
$message = 'The requested page could not be found.';
break;
default:
$message = 'We are sorry, but something went terribly wrong.';
}
return new Response($message);
});
Obviously replacing the example with your template.
See http://silex.sensiolabs.org/doc/usage.html#error-handlers
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How do I know whether the website is using robot.txt and sitemap.txt? I have done extracting keyword, description, title; however I am unable to find the way to code to check whther the website is using robot.txt and sitemap.txt.
I am doing something like this http://www.seoptimer.com/report/loadster.in/5553240531d12
Use file_get_contents:
$robotsContents = file_get_contents("http://targetdomain.com/robots.txt");
$sitemapContents = file_get_contents("http://targetdomain.com/sitemap.xml");
Check if contents are false, false will mean 404 Not Found, then check if it's not HTML contents (because some sites redirect every URL) with strpos($robotsContents, '<html') === false, if there is no tag, that mean it can be txt ou xml file.
So:
function pathExistsAndIsNotHtml($path) {
$contents = #file_get_contents($path);
return ! empty($contents) && strpos($contents, '<html') === false;
}
if(pathExistsAndIsNotHtml("http://targetdomain.com/robots.txt")) {
echo 'http://targetdomain.com/robots.txt';
} else {
echo 'There is no robots.txt';
}
if(pathExistsAndIsNotHtml("http://targetdomain.com/sitemap.xml")) {
echo 'http://targetdomain.com/sitemap.xml';
} else {
echo 'There is no sitemap.xml';
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i am trying to develop a website and i want that after entering correct username and password desired page should open. how i can achieve this.
if(...)
{
// code to verify login...
header("Location: http://page_to_forward_to/");
}
else { ... }
Hope this is what you are looking for
$url = "my/url/here";
Header("Location: $url");
exit();
you can use the header function:
header("location: www.example.com/yourpage.php");
Other possibility is to use javascript:
<script>
window.location = 'yourpage.php';
</script>