php - Is this way of using the method GET wrong? -
there i've been working , ran problem solve doing
header("location:messages.php?id_conversation=$row[id]");
is "wrong"?
this not wrong exactly. redirecting resource , passing information resource part of url, , acceptable.
however, part wrong way url structured. if going doing regularity, want habit of setting location precisely possible.
at least should set full path relative domain root:
header("location:/any_directories/messages.php?id_conversation=$row[id]");
and @ best, means including domain , protocol well:
header("location:https://yourdomain.com/any_directories/messages.php?id_conversation=$row[id]");
to simplify this, create helper function or object handle kind of redirect.
function redirect($url) { header("location:https://yourdomain.com/$url"); } redirect("any_directories/messages.php?id_conversation=$row[id]");
obviously there other considerations in above function, passing data query array maybe, discovering domain and/or protocol, etc, , should not used written, idea sound.
Comments
Post a Comment