Forum Moderators: coopster
My main php has a top pannel. There are links on the top of the pannel, and when I click links on the top, it should only change the bottom part of the page, and the top pannel stays the same.
I use this code to do what I just described
<a href = main.php?page=test.php>test</a>
The problem:
I created a admin function which allows admin of the website to enter data into the database. I ran into redirection problem when I finished entering data and clicked submit.
The data went into the database just fine; however, I want to go to a specific page after clicking submit. So I use this code:
include('main.php?page=test.php');
But it seems like include treats the whole line main.php?page=test.php as a filename. So it gives me an error says "cannot file the file" (something like that)
Does anyone have experience on this kind of problem?
Thanks
Opiston
[uk.php.net...]
However, make sure there is no output sent to the browser before you call this function or else you will see errors.
dc
test.php is a file which checks if all the fields in the box are filled with user inputs. If it doesn't have user input, then it should return to main.php?page=test.php for the user to try again. And it should also print out an error message. So I have to send an echo to the browser.
This is why I can't use header.
Thanks for your help
Opiston
<?php
include('../func.php');if($procedures_title == "") {
not_fill("Title");
}
else if($procedures_text == "") {
not_fill("Text");
}
else {
update_procedures($procedures_title, $procedures_text);
}header("Location: [$_SERVER[HTTP_HOST]...]
?>
When the program execute
header("Location: [$_SERVER[HTTP_HOST]...]does it still execute the if statements?
because when I try to access a variable in not_fill(), it returns nothing to me. So I was wondering if the function is actually executed.
A file called test_proc.php checks if the fields are filled in by the users. Here is the simple code of test_prc.php:
<?php
include('../func.php');if($procedures_title == "") {
not_fill("Title");
}
include("www.name.com/main.php?page=test.php");
?>
not_fill is in func.php; there is another function called print_err() in function that I will be using in a bit.
<?php
$msg;
function not_fill($message) {
global $msg;
$msg = $message;
}function print_err() {
global $msg;
print "testing";
print $msg;
}
?>
In test.php I have a code to print $msg with the function print_err():
<?php
include("../func.php");
print_err();
?>
But when test.php is called after test_proc.php, only "testing" is showing up on the screen and $msg has nothing in it.
I believe I am using global variable incorrectly. But I am not sure what's the best approach to this.
Regards
Opiston
Thanks for your help too, but I can't quite understand what you mean by
I declare global variables,set themand then include just 'index.php' and useCase to include the relevant file.
Could you explain a little more about that sentence.
I just started php about 1 month ago, so I am not too familiar with it.
Regards
Opiston
Thank you for your help
Opiston