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>
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 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');
}
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
I need help on how to make an API for PHP. I was trying to make one web server communicate with another webserver through PHP.
I also want it to update MySQL code. I was using $_GET but it was less secure. Here is my code, can you please take a look at it?
<?php
/*
example: website-url-here.com/?command=insert-command-here&password=testing
*/
$command = $_GET["command"];
$password = $_GET["password"];
if ($password == "testing") {
//Was not a good idea, less secure.
//echo eval($command);
//More secure
if ($command == "create-user")
{
//create user command here
}
else if ($command == "delete-user")
{
//delete user command here
}
else
{
die("Command is incorrect");
}
}
echo "Success";
?>
This question is way too open ended to answer in a StackOverflow answer. Try reading up a little on REST, and a lot on PDO, especially in the context of sanitizing user input.
Think about what would happen if somebody called your api with [url]?command=rm -rf .&password=testing