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:

Did you know?Explore Trending and Topic pages for more stories like this.
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

Async WSAConnect failed on XP with error code = 2 ("File not found")
Hi all,

I have very strange bug, please help me if you can.

It is reproduced o

how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy

Checking if a process is running (problems including psapi.dll i think...)
Ok, so all I'm trying to do is check if a program is running...

I've found out that I nee

login and redirect
hello! can someone help me.. can you give me an idea.. I want to make a login page and redirects it

Help with PHP Calendar code...
Hello, I'm new to this forum and I'm glad I found it.
I wrote this code for a PHP calendar as an

mail() problem
Hi Guys,

I've set up a contact email form. It sends the information fine, but it sends it to

search function
HI guys,

if anyone could point us in the right direction of how to do this, or provide some t

Displaying different page content, depending on the logged in user.
Hi all, I am new to ASP.net (and web development in general), and have a question about how I can di

Is it possible to put an entire 500-page book in a database with PHP?
I am working on an intranet and I was wondering if its possible to code php with mysql to enter a fu

Number Format
Hi All,

I have number '000000000050085' I want to format it to 500.85 Can any one give me

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