PHP redirect

How can I conditionally redirect the page with PHP?

Like…

If($redirect)
//do redirect
else
//no redirect

Thanks if you help.

header("location:site.com");

make sure whatever forwarding you’re doing is being done at the very begining of the page, other wise it wouldn’t work :slight_smile:

what if I have this as the first line in my PHP script:

<?php session_start(); ?>

hm… good question, cause both send header information… try having

<?php 
session_start(); 
if ( condition ) header("location:site.com");
?>