WAP noob needs help passing variables to PHP!

OK, I figured I'd try and get my head around WAP a bit cos I've been putting it off for ages. I downloaded the Nokia Internet Kit and I'm using that in conjunctin with Dreamweaver.

So far I've got...

First page shows an image then displays the main menu. Works fine.

One of the choices is 'Search by ID Code' and this opens the following page. Works fine too.

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
     <card id="idsearch" title="Got It Already?">             
          <p><small>
               Please enter your friends ID Code...             
          </small>
               <input name="IDCode" title="ID Code"/>
          <small>
          <anchor>
               Find
              <go href="idres.wml">
                   <postfield name="IDCode" value="$(IDCode)"/>
              </go>
          </anchor>
          <br/>
          <anchor title="Main Index">Main Index<go href="index.wml#index"/></anchor>      
          </small></p>      
     </card>
</wml>

Now I'm trying pass the variable IDCode into PHP which is where I'm getting problems.

If I do the following for idres.wml (which seems to be the way I'm supposed to based on examples in this forum) then I get "Can't open ../path/to/idres.wml?IDCode=12345 -  HTTP Error 500: Server error".

<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\">";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\">";
?>
<wml>
     <card id="idres" title="Got It Already?">
          <P>
      You entered <?php echo $_POST['IDCode']; ?>
          </P>
     </card>
</wml>

Where as if I do the following then the page loads but the variable is empty (just displays 'You entered')...

<?php
header("Content-type: text/vnd.wap.wml");
?>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
     <card id="idres" title="Got It Already?">
          <P>
      You entered <?php echo $_POST['IDCode']; ?>
          </P>
     </card>
</wml>

I have tried both as .wml files and .php files with the same results. Also, I can see from the error message above that the variable is present in the URL as it should be.

As far as I can tell I was following the examples right so it's probably something obvious. So if someone could point out the obvious to me that would be great.

Cheers,
Andy!
LVL 6
AndyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BigRatConnect With a Mentor Commented:
<go href="idres.wml">

needs to be :-

<go href="idres.wml" method="post">

since the default is "get" and consequently the "posted" value is not posted!
0
 
eicheledCommented:
Not knowing PHP, but there are inconsistencies in some of the tags (the ? character placement)

echo "<?xml version=\"1.0\">";

versus

<?xml version="1.0"?>

Just a shot in the dark :-)
0
 
AndyAuthor Commented:
Thanks but nope that's not it. That's just an oversite.
0
 
psycho_cat_69Commented:
Try this

You entered <?php echo $_GET['IDCode']; ?>
0
 
AndyAuthor Commented:
And here's me thinking that because it's a "post"field the method was post by default....

Anyway that plus a little rearranging of the headers seems to have done the trick.

Cheers!
0
All Courses

From novice to tech pro — start learning today.