By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,615 Members | 1,634 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,615 IT Pros & Developers. It's quick & easy.

Need some help on header refresh...

P: n/a
Harlow... i need some help on these... im actually trying to do a page
using php... the function is to receive certain parameters from a 3rd
party provider... and i need to redirect my page to another page after
certain validation. it's ok when i use the url to do the testing...
the validation part works fine... scenario as below:

if situation a, echo abc

if situation b, echo abc then refresh to another page.

the problem is after the 3rd party call my page the refresh doesnt
work... after doing some amendments, it redirects to another page but
doesnt echo abc... so any other way to redirect the page??? tried
output buffer start and flush but still couldn.... SOS...

Regards,
Justin

Mar 3 '07 #1
Share this Question
Share on Google+
19 Replies


P: n/a
Justin wrote:
Harlow... i need some help on these... im actually trying to do a page
using php... the function is to receive certain parameters from a 3rd
party provider... and i need to redirect my page to another page after
certain validation. it's ok when i use the url to do the testing...
the validation part works fine... scenario as below:

if situation a, echo abc

if situation b, echo abc then refresh to another page.

the problem is after the 3rd party call my page the refresh doesnt
work... after doing some amendments, it redirects to another page but
doesnt echo abc... so any other way to redirect the page??? tried
output buffer start and flush but still couldn.... SOS...

Regards,
Justin
You can use header() calls to redirect, but it is incompatible with
echo(). You can't send ANY output to the browser before a header() call.

But if you're redirecting, any output you send would not be displayed
anyway - so why bother sending it?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 3 '07 #2

P: n/a
On Mar 3, 11:29 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Justin wrote:
Harlow... i need some help on these... im actually trying to do a page
using php... the function is to receive certain parameters from a 3rd
party provider... and i need to redirect my page to another page after
certain validation. it's ok when i use the url to do the testing...
the validation part works fine... scenario as below:
if situation a, echo abc
if situation b, echo abc then refresh to another page.
the problem is after the 3rd party call my page the refresh doesnt
work... after doing some amendments, it redirects to another page but
doesnt echo abc... so any other way to redirect the page??? tried
output buffer start and flush but still couldn.... SOS...
Regards,
Justin

You can use header() calls to redirect, but it is incompatible with
echo(). You can't send ANY output to the browser before a header() call.

But if you're redirecting, any output you send would not be displayed
anyway - so why bother sending it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
er... the requirement from my 3rd party provider is that i have to
reply -1 once receive the parameters from them.. so i put echo -1. is
there any other way to send instead of echo? the redirecting part is
something i wan to add on... it's not in the API they provided...

Mar 3 '07 #3

P: n/a
Justin wrote:
On Mar 3, 11:29 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Justin wrote:
>>Harlow... i need some help on these... im actually trying to do a page
using php... the function is to receive certain parameters from a 3rd
party provider... and i need to redirect my page to another page after
certain validation. it's ok when i use the url to do the testing...
the validation part works fine... scenario as below:
if situation a, echo abc
if situation b, echo abc then refresh to another page.
the problem is after the 3rd party call my page the refresh doesnt
work... after doing some amendments, it redirects to another page but
doesnt echo abc... so any other way to redirect the page??? tried
output buffer start and flush but still couldn.... SOS...
Regards,
Justin
You can use header() calls to redirect, but it is incompatible with
echo(). You can't send ANY output to the browser before a header() call.

But if you're redirecting, any output you send would not be displayed
anyway - so why bother sending it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

er... the requirement from my 3rd party provider is that i have to
reply -1 once receive the parameters from them.. so i put echo -1. is
there any other way to send instead of echo? the redirecting part is
something i wan to add on... it's not in the API they provided...
OK, you have to respond with a -1. But once you send ANY output, you
can't use a header() call.

header() must be called before the headers are sent to the browser. And
any output - even white space - will cause the headers to be sent. So
you can either send a response or do the redirect. But the HTTP
protocol (not PHP) won't let you do both.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 3 '07 #4

P: n/a
What about a meta refresh instead of the header() function?

Mar 3 '07 #5

P: n/a
ro*******@gmail.com wrote:
What about a meta refresh instead of the header() function?
Does the third party browser understand meta refresh? I highly suspect
it doesn't - most non-browsers don't.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 3 '07 #6

P: n/a
Rik
Jerry Stuckle <js*******@attglobal.netwrote:
> er... the requirement from my 3rd party provider is that i have to
reply -1 once receive the parameters from them.. so i put echo -1. is
there any other way to send instead of echo? the redirecting part is
something i wan to add on... it's not in the API they provided...

OK, you have to respond with a -1. But once you send ANY output, you
can't use a header() call.

header() must be called before the headers are sent to the browser. And
any output - even white space - will cause the headers to be sent. So
you can either send a response or do the redirect. But the HTTP
protocol (not PHP) won't let you do both.
Allthough...
You can have a header redirect & output, I'm a bit fuzzy on wether this is
actually allowed with the HTTP protocol, but for instance, I can disable
automatic redirects (yes, also header redirects) in Opera, and I'll see
the content that comes next. So I see no practical reason why you cannot
send a redirect header & some content, as long as you set the header first
in PHP. There is a reason it's so often advised to die()/exit() after a
redirect statement.
--
Rik Wasmus
Mar 3 '07 #7

P: n/a
Dear Jerry,
You fully understand the situation im in right now... Mayb i will
elaborate more on this.
My application is to correspond with a mobile provider gateway
using HTTP calls. And meta refresh is not allowed.
Initially i din have to do any redirect as the process is actually
very simple. Once a mobile user register the service with their mobile
phone, the provider will call/send in the parameters to my
page(assuming receive.php). And upon receiving the parameters, i need
to echo "-1"; to the provider so a standard message will be sent out
to the registrant. The -1 is a requirement from my provider. So they
only recognized this. (according to their API). The reason why i have
to redirect is because some registrant might not be providing enough
information, so i did a strlen($sms) on the sms receive to see how
many characters is there and therefore determine whehter the info is
complete or not... So there are 2 situations, complete info and
incomplete info. Both i will reply -1 for them to receive the standard
sms but only those with incomplete info will receive a customized msg
from my side. That's the thing. If i put on the same page, those with
incomplete msg cant receive anything ask the provider only recognized
-1 for the registration process.... Thanx.

On Mar 4, 7:21 am, Rik <luiheidsgoe...@hotmail.comwrote:
Jerry Stuckle <jstuck...@attglobal.netwrote:
er... the requirement from my 3rd party provider is that i have to
reply -1 once receive the parameters from them.. so i put echo -1. is
there any other way to send instead of echo? the redirecting part is
something i wan to add on... it's not in the API they provided...
OK, you have to respond with a -1. But once you send ANY output, you
can't use a header() call.
header() must be called before the headers are sent to the browser. And
any output - even white space - will cause the headers to be sent. So
you can either send a response or do the redirect. But the HTTP
protocol (not PHP) won't let you do both.

Allthough...
You can have a header redirect & output, I'm a bit fuzzy on wether this is
actually allowed with the HTTP protocol, but for instance, I can disable
automatic redirects (yes, also header redirects) in Opera, and I'll see
the content that comes next. So I see no practical reason why you cannot
send a redirect header & some content, as long as you set the header first
in PHP. There is a reason it's so often advised to die()/exit() after a
redirect statement.
--
Rik Wasmus

Mar 7 '07 #8

P: n/a
Justin wrote:
>Jerry Stuckle <jstuck...@attglobal.netwrote:
>>> er... the requirement from my 3rd party provider is that i have to
reply -1 once receive the parameters from them.. so i put echo -1. is
there any other way to send instead of echo? the redirecting part is
something i wan to add on... it's not in the API they provided...
OK, you have to respond with a -1. But once you send ANY output, you
can't use a header() call.
header() must be called before the headers are sent to the browser. And
any output - even white space - will cause the headers to be sent. So
you can either send a response or do the redirect. But the HTTP
protocol (not PHP) won't let you do both.
Allthough...
You can have a header redirect & output, I'm a bit fuzzy on wether this is
actually allowed with the HTTP protocol, but for instance, I can disable
automatic redirects (yes, also header redirects) in Opera, and I'll see
the content that comes next. So I see no practical reason why you cannot
send a redirect header & some content, as long as you set the header first
in PHP. There is a reason it's so often advised to die()/exit() after a
redirect statement.
--
Rik Wasmus


Dear Jerry,
You fully understand the situation im in right now... Mayb i will
elaborate more on this.
My application is to correspond with a mobile provider gateway
using HTTP calls. And meta refresh is not allowed.
Initially i din have to do any redirect as the process is actually
very simple. Once a mobile user register the service with their mobile
phone, the provider will call/send in the parameters to my
page(assuming receive.php). And upon receiving the parameters, i need
to echo "-1"; to the provider so a standard message will be sent out
to the registrant. The -1 is a requirement from my provider. So they
only recognized this. (according to their API). The reason why i have
to redirect is because some registrant might not be providing enough
information, so i did a strlen($sms) on the sms receive to see how
many characters is there and therefore determine whehter the info is
complete or not... So there are 2 situations, complete info and
incomplete info. Both i will reply -1 for them to receive the standard
sms but only those with incomplete info will receive a customized msg
from my side. That's the thing. If i put on the same page, those with
incomplete msg cant receive anything ask the provider only recognized
-1 for the registration process.... Thanx.

On Mar 4, 7:21 am, Rik <luiheidsgoe...@hotmail.comwrote:
(Top posting fixed)

OK, so the registrant is coming through a provider to register with you.
The provider sends you some information and you respond with "-1".
The provider then sends a standard message to the registrant.

But you can't redirect the registrant because they aren't talking to you
in the first place. They're talking to the provider.

So how do you send a customized message to them?

Additionally, the fact this is coming from a cell phone is *very
relevant* and new information. It makes a huge difference. Most cell
phones don't have all the "bells and whistles" of regular browsers.

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 7 '07 #9

P: n/a
Dear Jerry,
There's a API provided to us by the provider, with the parameters
required and process of sending. So the situation is like this. In
order to prevent ppl from abusing the use of mobile contents(spam,
unnecessary charges to mobile users), the local telcos strictly
required us(content provider) to follow their registration process. A
specific keyword must be provided to indicate the registration
process. Assuming REG ABC is my keyword for the registration. Now i
want my subscribers to send in "REG ABC NAME ID AGE LOCATION". the
string will be one of the parameter i receive(lets put it as SMS). So
the parameters will be the mobile numbers, time, date, sms and so on.
The thing is the provider only take REG ABC into consideration, so
any numbers which send in a text msg to their server with the prefix
REG ABC will be routed to us(will call my php page). And i need to
repy -1 to acknowledge the receipts. Then the whole process is done.
But the thing is some of my subscribers leave out some important info
such as age, location etc (which is important to me but not the
provider) thats why i wanna send a msg to them ask them to provide the
additional info. (that is when the problem occurs). As the provider
only recognize REG ABC and -1 as a whole process, they dun care
whether the subscribers send in full msg or not. my side will have to
do the verification ourselves. That's why when i receive a msg with
incomplete info, i need to send them the msg, and this process is done
by using another method in the API.
I tried setting up a cron job or running the page with browser,
everything works well, the extra msg will be sent out. but when use
mobile phone to register, the page doesnt refresh/redirect. So they
only receive the standard msg from the provider. The standard msg is a
must as it's the requirements from the telcos. So i need to reply -1
first then only proceed with my own verification.

It's really nice meeting you here and thanx for being so helpful.

Regards,
Justin

Mar 8 '07 #10

P: n/a
Justin wrote:
Dear Jerry,
There's a API provided to us by the provider, with the parameters
required and process of sending. So the situation is like this. In
order to prevent ppl from abusing the use of mobile contents(spam,
unnecessary charges to mobile users), the local telcos strictly
required us(content provider) to follow their registration process. A
specific keyword must be provided to indicate the registration
process. Assuming REG ABC is my keyword for the registration. Now i
want my subscribers to send in "REG ABC NAME ID AGE LOCATION". the
string will be one of the parameter i receive(lets put it as SMS). So
the parameters will be the mobile numbers, time, date, sms and so on.
The thing is the provider only take REG ABC into consideration, so
any numbers which send in a text msg to their server with the prefix
REG ABC will be routed to us(will call my php page). And i need to
repy -1 to acknowledge the receipts. Then the whole process is done.
But the thing is some of my subscribers leave out some important info
such as age, location etc (which is important to me but not the
provider) thats why i wanna send a msg to them ask them to provide the
additional info. (that is when the problem occurs). As the provider
only recognize REG ABC and -1 as a whole process, they dun care
whether the subscribers send in full msg or not. my side will have to
do the verification ourselves. That's why when i receive a msg with
incomplete info, i need to send them the msg, and this process is done
by using another method in the API.
I tried setting up a cron job or running the page with browser,
everything works well, the extra msg will be sent out. but when use
mobile phone to register, the page doesnt refresh/redirect. So they
only receive the standard msg from the provider. The standard msg is a
must as it's the requirements from the telcos. So i need to reply -1
first then only proceed with my own verification.

It's really nice meeting you here and thanx for being so helpful.

Regards,
Justin
Hi, Justin,

Yes, it might work with a browser. But in the cell phone registration
process they aren't communicating with you - they're communicating with
their cell provider. And therein lies the problem.

When you respond, you're responding to the cellular provider. And you
can only send what they understand. Since you've indicated the only
thing they understand is a -1, that's all you can send. Anything else
will be kicked out by them.

When you test with the browser you don't have that intermediate step
(the cellular provider) so of course it works.

The only thing you can do is talk to the provider to see if there is an
extended interface you can use.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 8 '07 #11

P: n/a
Dear Jerry,
I found a solution... Since i couldn refresh the page, so i thought
off clearing the buffer, so i added ob_start() and ob_end_clean() in a
certain portion of the coding AND IT WORKSS!!!!!

Thanx anyway, great to meet u!!!

Regards,
Justin

Mar 9 '07 #12

P: n/a
Rik
Justin <ju****@smsit.com.mywrote:
Dear Jerry,
I found a solution... Since i couldn refresh the page, so i thought
off clearing the buffer, so i added ob_start() and ob_end_clean() in a
certain portion of the coding AND IT WORKSS!!!!!
You haven't solved the problem, you've just masked it. The placing of
those 2 commands should give you a clue where you're sending content,
search that and remove it.

Your solution is like moving the couch to hide the nasty stain in the
carpet: the stain is still there, your carpet is not as it should be, it
just seems that way for now.
--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel
Mar 9 '07 #13

P: n/a
Actually REFRESH is a solution but the OB is an alternative as the
provider only accept -1 output(compulsory to reply -1, echo -1;), but
the sending additional message part doesnt require me to reply
anything upon receiving th parameters from the provider. So i just
need to "hide" the return parameters from the provider. Thanx.

Mar 9 '07 #14

P: n/a
Justin wrote:
Actually REFRESH is a solution but the OB is an alternative as the
provider only accept -1 output(compulsory to reply -1, echo -1;), but
the sending additional message part doesnt require me to reply
anything upon receiving th parameters from the provider. So i just
need to "hide" the return parameters from the provider. Thanx.
Which means you're not actually sending the return parameters to the
provider.

Not good.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 9 '07 #15

P: n/a
Dear Jerry,
The return parameters were actually provided by the provider...
Purpose is for me to capture the status of the sent msg (delivered,
undelivered, pending etc). but they already gave us a interface to
check out on the status and it's not necessary for me to keep track on
my own server. But if i do, all i have to do is to insert the
parameters returned into my DB and then only clear the output buffer.

The parameters i sent to them is different as i use require"http://
xx.xx.xx?xx=xx"; to call the provider page so there shouldnt be any
output on my side.

Regards,
Justin

Mar 9 '07 #16

P: n/a
Justin wrote:
Dear Jerry,
The return parameters were actually provided by the provider...
Purpose is for me to capture the status of the sent msg (delivered,
undelivered, pending etc). but they already gave us a interface to
check out on the status and it's not necessary for me to keep track on
my own server. But if i do, all i have to do is to insert the
parameters returned into my DB and then only clear the output buffer.

The parameters i sent to them is different as i use require"http://
xx.xx.xx?xx=xx"; to call the provider page so there shouldnt be any
output on my side.

Regards,
Justin
Justin,

From your first post:

if situation a, echo abc

if situation b, echo abc then refresh to another page.

So you're not echoing abc.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 9 '07 #17

P: n/a
Sorry, maybe i din state clearly in my post, the echo abc is actually
the echo -1... Sorry for that.

Mar 10 '07 #18

P: n/a
Rik
Justin <ju****@smsit.com.mywrote:
Sorry, maybe i din state clearly in my post, the echo abc is actually
the echo -1... Sorry for that.
You missed the point.

By discarding the buffer you're not outputting anything, at least not
anything that's outputted after the buffer started. If you output
something useless there (a not required message, or perhaps just
whitespace) you should prevent that output in the first place, if you are
outputting something usefull there (in this case '-1'), it won't be sent,
and is discarded.
--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel
Mar 10 '07 #19

P: n/a
Justin wrote:
Sorry, maybe i din state clearly in my post, the echo abc is actually
the echo -1... Sorry for that.
Exactly as Rik indicated.

Whether it is "abc", -1, or the complete works of Shakespeare - the
point is you are throwing it away and not outputting anything.

If it's a required response, you're not sending it. If it's not a
required response, why even echo it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 10 '07 #20

This discussion thread is closed

Replies have been disabled for this discussion.