Forum Moderators: coopster
I've got a form that has a number of buttons. On submit, certain functions are called and, depending on which button was pressed, certain things are processed. So far, that part works fine.
However, in two instances (add record and edit record) I want to display two different pages. This is where I'm having the problem.
As you can see below in the code sample, if $buttonHit == Edit - I want to display edit_row.php; ELSE I want to display Add_row.php.
if ($buttonHit == 'Delete'){
deleteEntry($rowId);
} else if ($buttonHit == 'Edit') {
// LOAD EDIT_ROW.PHP;
} else {
// LOAD ADD_ROW.PHP;
}
Seemed straight forward enough to me at the outset, but I can't find the right .php function or syntax to get the job done.
I know I'm probably doing this the hard way: I've read issues about a page being able to call it self based upon a condtion but, for me, I really need to take this one step at a time (I am an absolute beginner at php) or else my brain starts to frost over.
As always, any help and guidence is greatly appreciated.
Neophyte
if ($buttonHit == 'Delete'){
deleteEntry($rowId);
} else if ($buttonHit == 'Edit') {
header("Location: /EDIT_ROW.PHP");
} else {
header("Location: /ADD_ROW.PHP");
}
Actually tried that afternoon after scouring the internet for a solution to this problem before I went about bothering the membership here.
Here's the code with header included:
if ($buttonHit == 'Delete'){
deleteEntry($rowId);
} else if ($buttonHit == 'Edit') {
header("Location: /con_edit_entry.php");
//editEntry($rowId);
} else {
header("Location: /con_add_entry.php");
//addEntry();
here's what I get when I try and use the header function:
Warning: Cannot modify header information - headers already sent by (output started at c:\apache\htdocs\learning_php\con_process_change.php:11) in c:\apache\htdocs\learning_php\con_process_change.php on line 21
"con_process_change" is the page which evaluates the $_POST variable and then redirects to the "add" or "edit" page based upon the condition statement.
I'm sure it's "operator error" on my part, but I don't know where the error lies.
Neophyte
"Cannot modify header information"
refers to the fact that you have already sent some content back to the client browser e.g. <html> or something (this is includes single spaces). To use the header function you mustn't send anything back to the browser before its called.
You'll have to check your code and see if you can call the header function before you send any HTML etc.
HTH
[php.net...]
Saurabh.