Web Hosting Talk







View Full Version : variable redirecting?


stuffradio
06-05-2007, 06:28 PM
I use this code to redirect:


echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=members.php">';


Can I just do members.php?id=$user[id] where members.php is so when I'm done updating stuff it'll redirect to the user you're editing? Or is there an easier way.

bilalk
06-05-2007, 06:44 PM
PHP doesn't replace variables like $user within single quotes, so you'd end up doing something like this:


echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=members.php?id=' . $user['id'] . '">';


Note that I'm ending the quotes and then adding the strings together using "." (this is called a [i]concatenation operator, it puts strings together).
It's also recommended to use $user['id'] instead of $user[id], for both performance and correctness reasons (see the PHP Manual: Why is $foo[bar] wrong? (http://us.php.net/manual/en/language.types.array.php)).

This should fit your goal of redirecting with the member ID.

stuffradio
06-06-2007, 01:10 AM
thanks for that, works like a charm!

I am making invoices for this website.. basically I want to use a cron job to run every day... check if it's been a week. If it has, perform some stuff for the unique user(s). How do I do that? I'm using


date('Y/m/d');