Ask a Question related to PHP Development, Design and Development.
-
Bob Bedford #1
create variable before redirection.
I'm trying to set a variable before redirection. Here is the code:
//header("Location: /ManageProfile.php?UserID=".$id);
echo("<input name=\"UserID\" type=\"Hidden\" id=\"UserID\"
value=\"".$id."\">");
header("Location: /ManageProfile.php");
The commented line works fine but has the UserID in the URL, and I must
avoid this. Instead, the second syntax does not work. I've error Cannot
modify header information - headers already sent by.....
It's there any way to redirect the page other than header. (I come from ASP,
and there was a response.redirect that allow this, I mean to set values in
hidden variables and then redirect.)
Please help....
Bob Bedford Guest
-
Using a Variable to create the SQL Query
I need to create a "dynamic" Update query. I want to store the meet of the command in a variable and then reference the variable in in query. ... -
Create Variable
Hi, I wanted to ask, how can I for Simple Connection component, username text field, set a variable? Thanks Lanex:beer; -
Create custom CGI. variable
Does anyone know how I could create a variable that would appear in the #cgi# scope ? I have x number of coldfusion servers and on each one of... -
create a dynamic variable
Hi ! i would like to know how to create a dynamic variable with flash. I'm getting 2 strings from XML and would like to create a variable named... -
header() redirection/session variable problem
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication... -
Alvaro G Vicario #2
Re: create variable before redirection.
*** Bob Bedford wrote/escribió (Thu, 11 Dec 2003 15:29:33 +0100):
This is not a PHP issue. No matter how you do it (ASP, PHP, cgi-bin...),> It's there any way to redirect the page other than header. (I come from ASP,
> and there was a response.redirect that allow this, I mean to set values in
> hidden variables and then redirect.)
the final result is sending an HTTP redirect header to browser. And you
can't send HTTP headers once you've started sending normal output.
What's the purpose of sending an HTML form just before a redirect?
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Alvaro G Vicario Guest
-
Matthew Crouch #3
Re: create variable before redirection.
"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:ony8h32eso5n.ql1mb7gj0chl.dlg@40tude.net...I've got a purpose for it, since I think I need the same...>
> What's the purpose of sending an HTML form just before a redirect?
>
>
I want to send order info into the dB when the usr clicks a Paypal button,
which redirects to their paypal account.
I'm guessing the <action="doit.php"> should :
doit.php
<?
//put the stuff from the form into the dB
header(paypal.com...);
and so on...
?>
Am I going about this wrong?
Matthew Crouch Guest
-
Jedi121 #4
Re: create variable before redirection.
"Bob Bedford" a écrit le 11/12/2003 :
You must not echo() before a Header() because doing this PHP does send> I'm trying to set a variable before redirection. Here is the code:
>
> //header("Location: /ManageProfile.php?UserID=".$id);
> echo("<input name=\"UserID\" type=\"Hidden\" id=\"UserID\"
> value=\"".$id."\">");
> header("Location: /ManageProfile.php");
>
> The commented line works fine but has the UserID in the URL, and I must
> avoid this. Instead, the second syntax does not work. I've error Cannot
> modify header information - headers already sent by.....
>
> It's there any way to redirect the page other than header. (I come from ASP,
> and there was a response.redirect that allow this, I mean to set values in
> hidden variables and then redirect.)
>
> Please help....
the header then the content of the echo().
The way you explain it I understand you need to send a POST variable.
I would consider using a HTML form auto-submitted by some JavaScript.
Otherwose why don't you send GET data ?
--
Avez-vous lu le manuel?
[url]http://www.php.net/manual/fr/[/url]
Jedi121 Guest
-
Bob Bedford #5
Re: create variable before redirection.
As said in my message, I won't the variables to be sent in the URL.
On ASP, you can do a Response.redirect after setting some values.
Here I want to set values before redirecting to an other page.
It's there any similar that let me do the same as Header, but letting me to
set some values first ?
"Anyway, oui, j'ai lu le manuel, et j'ai rien trouvé..."
"Jedi121" <jedi121news@free.fr.Removethis> a écrit dans le message de
news:mesnews.5cb87d3c.5ce65d61.332.2689@free.fr.Re movethis...ASP,> "Bob Bedford" a écrit le 11/12/2003 :> > I'm trying to set a variable before redirection. Here is the code:
> >
> > //header("Location: /ManageProfile.php?UserID=".$id);
> > echo("<input name=\"UserID\" type=\"Hidden\" id=\"UserID\"
> > value=\"".$id."\">");
> > header("Location: /ManageProfile.php");
> >
> > The commented line works fine but has the UserID in the URL, and I must
> > avoid this. Instead, the second syntax does not work. I've error Cannot
> > modify header information - headers already sent by.....
> >
> > It's there any way to redirect the page other than header. (I come fromin> > and there was a response.redirect that allow this, I mean to set values>> > hidden variables and then redirect.)
> >
> > Please help....
> You must not echo() before a Header() because doing this PHP does send
> the header then the content of the echo().
> The way you explain it I understand you need to send a POST variable.
> I would consider using a HTML form auto-submitted by some JavaScript.
> Otherwose why don't you send GET data ?
>
> --
> Avez-vous lu le manuel?
> [url]http://www.php.net/manual/fr/[/url]
>
Bob Bedford Guest
-
Bob Bedford #6
Re: create variable before redirection.
Hi Alvaro, thanks for your reply,
I've my page: login.php. The form in login.php has the result in itself. So
after sumbitting itself, I must check if the user exists. If yes, I must
redirect to the manage.php. The manage PHP must know wich is the selected
user (giving the UserID).
The UserID, for now, is in the URL:
header("Location: /ManageProfile.php?UserID=".$id);
Is what I'm trying to avoid. I don't want the user to see wich UserID it
has.
That seems to be a very common problem, why the solution would be so
difficult ????
BoB
"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> a écrit
dans le message de news:ony8h32eso5n.ql1mb7gj0chl.dlg@40tude.net...ASP,> *** Bob Bedford wrote/escribió (Thu, 11 Dec 2003 15:29:33 +0100):> > It's there any way to redirect the page other than header. (I come fromin> > and there was a response.redirect that allow this, I mean to set values>> > hidden variables and then redirect.)
> This is not a PHP issue. No matter how you do it (ASP, PHP, cgi-bin...),
> the final result is sending an HTTP redirect header to browser. And you
> can't send HTTP headers once you've started sending normal output.
>
> What's the purpose of sending an HTML form just before a redirect?
>
>
> --
> --
> -- Álvaro G. Vicario - Burgos, Spain
> --
Bob Bedford Guest
-
Jedi121 #7
Re: create variable before redirection.
"Bob Bedford" a écrit le 11/12/2003 :
Maybe but not in PHP as far as I know.> As said in my message, I won't the variables to be sent in the URL.
>
> On ASP, you can do a Response.redirect after setting some values.
> Here I want to set values before redirecting to an other page.
As I said the only solution I see then is an HTML form containing
hidden var you auto-submit via JavaScript.
I use automated signature on these newsgroup because many of the> It's there any similar that let me do the same as Header, but letting me to
> set some values first ?
>
> "Anyway, oui, j'ai lu le manuel, et j'ai rien trouvé..."
questions can be answered by a good reading of the official manual.
Don't take it personnaly.
Jedi121 Guest
-
Bob Bedford #8
Re: create variable before redirection.
"Jedi121" <jedi121news@free.fr.Removethis> a écrit dans le message de
news:mesnews.5d267d3c.ec7fc11c.339.2689@free.fr.Re movethis...I've tried this, but don't seems to work:> "Bob Bedford" a écrit le 11/12/2003 :>> > As said in my message, I won't the variables to be sent in the URL.
> >
> > On ASP, you can do a Response.redirect after setting some values.
> > Here I want to set values before redirecting to an other page.
> Maybe but not in PHP as far as I know.
> As I said the only solution I see then is an HTML form containing
> hidden var you auto-submit via JavaScript.
<form name="voidform" method="GET">
<input name="PrevPage" type="hidden" value="ManageProfile.php">
<input name="UserID" type="hidden" value="<?PHP echo($id);?>">
</form>
<table width="100%" border="0">
<tr>
<td><a href="EditUser.php?UserID=<?PHP echo($id);?>">Modifier
données utilisateur</a></td>
....
Isn't possible to set those values without a form. I've seen $global, or it
is possible to store values in the $session variable to pass them trought
the pages.
to> > It's there any similar that let me do the same as Header, but letting meWasn't taked personally ;-) I guessed it was an automated signature.>> > set some values first ?
> >
> > "Anyway, oui, j'ai lu le manuel, et j'ai rien trouvé..."
> I use automated signature on these newsgroup because many of the
> questions can be answered by a good reading of the official manual.
> Don't take it personnaly.
>
Bob Bedford Guest
-
Andy Hassall #9
Re: create variable before redirection.
On Thu, 11 Dec 2003 21:03:30 +0100, "Bob Bedford"
<bedford1@YouKnowWhatToDohotmail.com> wrote:
That's because of buffering. You can do the same in PHP, if you really want.>On ASP, you can do a Response.redirect after setting some values.
>Here I want to set values before redirecting to an other page.
[url]http://www.php.net/manual/en/ref.outcontrol.php[/url]
Although it's a bit of a waste of time outputting data but then redirecting
away from it before it's seen.
--
Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
Andy Hassall Guest
-
Jedi121 #10
Re: create variable before redirection.
"Bob Bedford" a écrit le 11/12/2003 :
Then you need to submit this form via a JavaScript function adding this> I've tried this, but don't seems to work:
> <form name="voidform" method="GET">
> <input name="PrevPage" type="hidden" value="ManageProfile.php">
> <input name="UserID" type="hidden" value="<?PHP echo($id);?>">
> </form>
line in your HTML section :
<script language="JavaScript">document.form[0].submit();</script>
$global is just valid during the execution of the current script not> <table width="100%" border="0">
> <tr>
> <td><a href="EditUser.php?UserID=<?PHP echo($id);?>">Modifier
> données utilisateur</a></td>
> ...
>
> Isn't possible to set those values without a form. I've seen $global, or it
> is possible to store values in the $session variable to pass them trought
> the pages.
form one script to another.
But yes you can use sessions but then you must set the correct values
of PHP.ini to be sure this data won't be shown in the URL. Depending if
you tolerate the use of cookies or not.
--
Have you read the manual ?
[url]http://www.php.net/manual/en/[/url]
Jedi121 Guest
-
Alvaro G Vicario #11
Re: create variable before redirection.
*** Bob Bedford wrote/escribió (Thu, 11 Dec 2003 21:09:01 +0100):
That's a typical usage for sessions. You set a session variable and> I've my page: login.php. The form in login.php has the result in itself. So
> after sumbitting itself, I must check if the user exists. If yes, I must
> redirect to the manage.php. The manage PHP must know wich is the selected
> user (giving the UserID).
>
> The UserID, for now, is in the URL:
> header("Location: /ManageProfile.php?UserID=".$id);
>
> Is what I'm trying to avoid. I don't want the user to see wich UserID it
> has.
redirect afterwards:
$_SESSION['id']=$id;
header("Location: [url]http://www.site.com/ManageProfile.php);[/url]
exit;
Then you have that variable available everywhere:
echo $_SESSION['id'];
BTW, this code is untested, check sessions manual chapter.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Alvaro G Vicario Guest
-
Alvaro G Vicario #12
Re: create variable before redirection.
*** Bob Bedford wrote/escribió (Thu, 11 Dec 2003 21:03:30 +0100):
Do you mean ASP.NET? In old-fashioned ASP I can't remember you could do> On ASP, you can do a Response.redirect after setting some values.
> Here I want to set values before redirecting to an other page.
such a thing. Well, you could set any value you want (just like in PHP) but
you can't send it to the redirected page unless you use URL, cookies or
sessions.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Alvaro G Vicario Guest
-
Bob Bedford #13
Re: create variable before redirection.
"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> a écrit
dans le message de news:19gusk0oqerab.10n1bdt76wjds.dlg@40tude.net...but> *** Bob Bedford wrote/escribió (Thu, 11 Dec 2003 21:03:30 +0100):>> > On ASP, you can do a Response.redirect after setting some values.
> > Here I want to set values before redirecting to an other page.
> Do you mean ASP.NET? In old-fashioned ASP I can't remember you could do
> such a thing. Well, you could set any value you want (just like in PHP)sessions also create cookies, and this is a problem, since if the user> you can't send it to the redirected page unless you use URL, cookies or
> sessions.
disable cookies, I get stuck and can't manage the session correctly.
I'm looking for an other way to do so. I've been told to use a javascript
that submit the form automatically, maybe I'll try this.
Thanks for help.
Bob Bedford Guest



Reply With Quote

