![]() |
#1 |
Junior Member
Join Date: Jul 2006
Posts: 16
|
![]()
What's wrong with this code please:
if (DG_ACTION == 'details'){ echo ''; } I just want to redirect to a new page when DG_ACTION = 'details'. Thanks, Rob |
![]() |
![]() |
![]() |
#2 |
Junior Member
|
![]()
try the header function. http://us2.php.net/manual/en/function.header.php
something like: header('Location: http://localhost/Talonhenge/birddetails.php'); . |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Jul 2006
Posts: 16
|
![]()
Tried that...I'm getting the following error when I do it
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\Talonhenge\docs1.php:8) in C:\Program Files\xampp\htdocs\Talonhenge\docs1.php on line 111 This is what I originally used: header( 'Location: http://localhost/Talonhenge/birddetails.php',true ) ; This is what's at line 8: Thanks. |
![]() |
![]() |
![]() |
#4 | |
Junior Member
|
![]()
Quote:
yep, while I am far from an expert, I know that that means you've already started sending output to be displayed. even a simple ECHO that comes before header function will cause that error. if there is no way to avoid the output (and PHP was designed to be embedded in the output), you could try something like:
PHP Code:
. |
|
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Jul 2006
Posts: 16
|
![]()
That did it!. Thanks alot!
|
![]() |
![]() |
![]() |
#6 |
Ambitious Member
Join Date: Jun 2006
Location: Sydney, Australia
Posts: 26
|
![]()
A sematic alternative (although it's a little bit of a hack) is to use ob_start() at the start of your page and ob_end_flush(); at the end of your page.
PHP Code:
I say that it's a bit of a hack because you should have all page controlling functionality handled before anything is sent to be displayed to the browser. HTH Regards,
__________________
R. Villar David Web Developer http://rvdavid.blogspot.com/ |
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Jul 2006
Posts: 16
|
![]()
R.Villar David
I figured I would need to control page and db access at the beginning. I'm somewhat new to web development. Would you happen to have some standard script available that shows some general guidelines on page security. If not, can you point me to a reference . Thanks. |
![]() |
![]() |
![]() |
#8 |
Ambitious Member
Join Date: Jun 2006
Location: Sydney, Australia
Posts: 26
|
![]()
I can't say that I have scripts that you can learn from, I write all PHP code in Classes and methods, programming more in the Object Oriented Paradigm rather than Procedural at this stage.
I do however have some tips for you ![]() For starters - Google is your friend ![]() Search results for "PHP Guidelines" Another good link http://phpsec.org/php-security-guide.pdf from http://phpsec.org/ Now these below are not about security or anything like that, but, they are some guidelines that have helped me out when I was first starting out. Thinking semantics - first rule would be to separate presentation (HTML/XHTML) and business(php code which acquires data from databases, coditional statements anything that isn't echoing out prepepared temporary variables) logic separate. An acronymn that will get you started: DRY = Don't Repeat Yourself. If you find that you are copying and pasting all the time, then you are doing something wrong. Either place repetitive code into functions (Procedural) or classes (Object Oriented). Use Versioning Software (CVS or SubVersion/SVN). Why? because it helps you manage versions of your code. Especially now that you are trying to learn new things and experimenting. Learn Unit Testing. This is more for OOP, but it does work for Procedural if this is the paradigm of your choice. These are a few of the general guidelines that I've been given when I was starting out. If you have any specific questions feel free to ask. How these help you out, good luck with it. Regards,
__________________
R. Villar David Web Developer http://rvdavid.blogspot.com/ |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|