Reditecting pages based on logic


Posted on 16th Feb 2014 07:03 pm by admin

Newbie here, apologies in advance!

I am trying to use the header function to forward one of any number of locations (taken from a db) based on the value of a response param:

Quote<?php include '../include/db/db-open.php'; ?>
<?php
$postTypeId = $_POST['postTypeId'];
$postTypesResults = $mysqli->query("select id, editPageUrl from post_types where active = 1");
?>
<?php include '../include/db/db-close.php'; ?>
<?php
while ($postTypesResult = $postTypesResults->fetch_object()) {
if ($postTypesResult->id == $postTypeId) {
header("Location: ".$postTypesResult->editPageUrl);
}
}
?>

The value of $postTypeId is always blank if echoed (explining why the condition to forward is never met).

Two questions:
Is there anything obvious I am doing wrong causing $postTypeId to always be blank?Can the header function be used in this way?
Thanks

No comments posted yet

Your Answer:

Login to answer
191 Like 24 Dislike
Previous forums Next forums
Other forums

Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to

Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re

Writing to the middle of a file
Hi I have a bit of a problem. Is there any way i can write some text to a middle of a text file. For

Checking if variable is 0 as opposed to NULL/Empty...
I'm trying to write some code that will retrieve a user's access level from my database and if it do

Undefined Variable: PHP_SELF, pls help
Hi,

Im a newbie on PHP / MySQL programming and Im running a script to search one field on my

Execure stored procedure on a timer
Can someone tell me an easier way to execute a stored procedure on a timer? I am using Oracle 10g R

There was a problem with the request. (Code: 0)
Any Idea what could cause this? I get it randomly at best. But with both IE and FF. It derives from

Need help Updating SQL Server Express DB from c# :(
Please can anyone help with:-
1 How to sructure the strSelect statement.
2 How to instruct

Multiple Pages
Hi. Im very new to php. I'm trying to create a basic login/registration page.

So I have a bas

At max how many columns is advisable to create in a table/view
Hi All,
I have two transaction table from which i want to create a simple view or material

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash