Solved

WAP noob needs help passing variables to PHP!

Posted on 2004-03-29
5
555 Views
Last Modified: 2013-12-27
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!
0
Comment
Question by:Reapz
5 Comments
 
LVL 3

Expert Comment

by:eicheled
ID: 10710659
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
 
LVL 6

Author Comment

by:Reapz
ID: 10711715
Thanks but nope that's not it. That's just an oversite.
0
 
LVL 1

Expert Comment

by:psycho_cat_69
ID: 10713125
Try this

You entered <?php echo $_GET['IDCode']; ?>
0
 
LVL 27

Accepted Solution

by:
BigRat earned 250 total points
ID: 10713562
<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
 
LVL 6

Author Comment

by:Reapz
ID: 10713685
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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now