I am trying to access a database through a cell phone. First page you enter a name to search for. This returns results on a second page.
I am able to enter a search name and it returns incorrect results from the database because for some reason the input parameter is not getting passed from the main wml page to the php code.
Here is the first page
Code:
<?php
Header("Content-type: text/vnd.wap.wml");
Header("Cache-Control: no-cache, must-revalidate");
Header("Pragma: no-cache");
echo ("<?xml version='1.0'?>");
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml" >
<wml>
<card id="search" title="SaintSearch">
<p>
<do type="accept">
<go href="index2.php" method="post">
<postfield value="$skier"/>
</go>
</do>
Name: <input title="Name" name="skier"/>
</p>
</card>
</wml>
HERE IS THE PHP page
Code:
<?php
Header("Content-type: text/vnd.wap.wml");
printf("<?xml version=\"1.0\"?>\n");
printf("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" "
."\"http://www.wapforum.org/DTD/wml_1.1.xml\" >\n");
printf("<wml>\n");
?>
<wml>
<card id="index2" title="sql">
<?php
@ $db = mysql_pconnect('localhost', 'xxx', 'xxxxx');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
mysql_select_db('saintData') or die (mysql_error()."<br />Couldn't select database");
$query = "select lastname, firstname from skiers where (firstname like '%$chicken%' or lastname like '%$skier%') AND (is_hidden = '0')";
$result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
print $row["lastname"]."<br>\n";
}
mysql_free_result($result);
?>
</card>
</wml>