Page 1 of 1

Hi, new to php and new quick help on php/wml...

Posted: Wed Nov 22, 2006 9:44 am
by x2srj
Hi,

I've got a wml page that passes a variable:

<go href="bookingref_truncate.php?bookref=MU4657">

this goes to a PHP page like....

<card id="booking">
<onevent type="ontimer">
<go href="search.wml#step1">

Code: Select all

<?php

$changeBookref = substr('bookref', 0, 2);

if ($changeBookref == "AB"){
   echo "<setvar name=\"bookref\"   value=\"ABBA\" />";
   }
else ($changeBookref == "MU"){
   echo "<setvar name=\"bookref\"   value=\"MUSE\" />";
   }
blah blah blah blah blah blah

This PHP page I need to do two things; one I need to truncate the value to just the first two alphanumerics; and secondly I need the if statement to pick up the value and pass it correctly... The trouble I'm having is I don't appear to be getting the value???

help PLEASE Smiley

Many many thanks in advance Smiley

Posted: Wed Nov 22, 2006 9:52 am
by volka

Code: Select all

<?php echo substr('bookref', 0, 2); ?>
prints bo
You probably want the first two characters of the http parameter bookmark not the string 'bookmark'. $_GET is an array/hash that stores the http parameters passed via GET (as part of the uri).
try

Code: Select all

$changeBookref = substr($_GET['bookref'], 0, 2);

Posted: Wed Nov 22, 2006 1:59 pm
by x2srj
Many many thanks :)