For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > June 2005 > js issue to php









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author js issue to php
Peter Van Hove

2005-06-03, 3:56 pm

A currently existing page is handed a value like this :

page.htm?code

in the html of that page :


Peter Van Hove

2005-06-03, 3:56 pm

A currently existing page is handed a value like this:
page.htm?code_value


in the html of that page :

<script type="text/javascript">

code = (self.location.search) ? self.location.search.substring(1) :
"none";

if (code == "code_value")
{
// build url ...
}

</script>



I want to change the js to php ... but how do I get the code value ?
because, if I understand correctly, php would expect ?code=value


Kimmo Laine

2005-06-03, 3:56 pm

"Peter Van Hove" <Will_Bounce_So_Use_My_First_Name@Smart-Projects.net> wrote
in message news:AeYne.109259$KF7.6591578@phobos.telenet-ops.be...
>A currently existing page is handed a value like this:
> page.htm?code_value
>
>
> in the html of that page :
>
> <script type="text/javascript">
>
> code = (self.location.search) ? self.location.search.substring(1) :
> "none";
>
> if (code == "code_value")
> {
> // build url ...
> }
>
> </script>
>
>
>
> I want to change the js to php ... but how do I get the code value ?
> because, if I understand correctly, php would expect ?code=value



Elementary, dear Watson.

<?php

$code = $_SERVER['QUERY_STRING'];

if($code=="code_value"){
// build code
}
?>


--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com


Colin McKinnon

2005-06-03, 3:56 pm

Peter Van Hove wrote:

> A currently existing page is handed a value like this:
> page.htm?code_value
>


Although the part of a URL you have shown may be correct, I've never seend
this format being used before and you may be storing up problems by keeping
the format (instead of, say, page.html?code_value=1).

Running as a module PHP should have full view of the requested URI. Try
phpinfo() for the right variable to use. It wont automatically
aassign/create a variable wrt 'code_value'.

HTH

C.


Peter Van Hove

2005-06-03, 3:56 pm


thx, works.


Peter Van Hove

2005-06-03, 3:56 pm

It may not be the most beautiful solution but it stays compatible this way
with the earlier implementation.
Life is hard ... ;-)


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com