Mobile Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreMobile Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 28th, 2007, 09:08 AM
sunyukta sunyukta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 sunyukta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m
Reputation Power: 0
Passing $_POST data with postfield (was: Hi...desperately need help)

hello there,
i just started doing some programming in wml. actually, iv almost completed some work on a web site, and right now im just converting it to wml. im getting problems with $_POST, i never actually get the values. in one of them, when im executing a query, instead of having a value( i tried to print it to check) i only get the variable names.

im posting one bmi checker, it doesnt need any database tables. im getting a division by zero error, maybe because i didnt pass the variables well...could you have a look at it? thanks a lott,
yuk****a


php Code:
Original - php Code
  1. <?php
  2. function quote_smart($value)
  3. {
  4.     // Stripslashes
  5.  
  6.     if ( get_magic_quotes_gpc() )
  7.  
  8.     {
  9.  
  10.         $value = stripslashes( $value );
  11.  
  12.     }
  13.  
  14.     // Quote if not a number or a numeric string
  15.  
  16.     if ( !is_numeric( $value ) )
  17.  
  18.     {
  19.  
  20.         $value = "'" . mysql_real_escape_string($value) . "'";
  21.  
  22.     }
  23.  
  24.     return $value;
  25.  
  26. }
  27.  
  28.  
  29.  
  30. header("Content-type: text/vnd.wap.wml");
  31. echo '<?xml version="1.0" encoding="utf-8"?>
  32. <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "(URL address blocked: See forum rules)">
  33. ';
  34. ?>
  35. <wml>
  36.  
  37.  
  38. <do type="prev" name="prev" label="Go Back"><prev/></do>
  39.  
  40. <template>
  41.     <do name="menu_1" type="accept" label="Home">
  42.       <go href="#menu_tc"/>
  43.     </do>
  44.     <do name="menu_2" type="accept" label="Log In ">
  45.       <go href="http://localhost/clic/login.php"/>
  46.     </do>
  47.     <do name="menu_3" type="accept" label="Find A Doctor">
  48.       <go href="http://localhost/FindADoc.php"/>
  49.     </do>
  50.     <do name="menu_4" type="accept" label="Make an appointment">
  51.       <go href="#makeapp"/>
  52.     </do>
  53.     <do name="menu_5" type="accept" label="Look up a medical term">
  54.       <go href="(URL address blocked: See forum rules)"/>
  55.     </do>
  56.     <do name="menu_6" type="accept" label="Health tools">
  57.       <go href="http://localhost/clic/bmi.php"/>
  58.     </do>
  59.     <do name="menu_7" type="accept" label="About Medi Care Clinic">
  60.       <go href="contact.wml"/>
  61.     </do>
  62.     <do name="menu_8" type="accept" label="Contact Us">
  63.       <go href="contactus.wml"/>
  64.     </do>
  65.  
  66.   </template>
  67. <card id="main" title="BMI Calculator"><p><strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MediCare Clinic </strong>
  68. <p>Health Calculator
  69.     <p> &nbsp;Please input your height, weight and waist size. This calculator will generate a brief report on your general health status, based on the BMI (Body Mass Index).
  70.  
  71.    
  72.  
  73.                 &nbsp;&nbsp;
  74.  
  75.                 &nbsp;
  76.     <p>&nbsp;Height(cm): &nbsp;
  77.  
  78. &nbsp;<input type="text" name="height" emptyok="false" />
  79. <p>
  80. Weight(kg):&nbsp; <input type="text" name="weight" emptyok="false" />&nbsp;      
  81. <p></p>
  82.                    
  83. <do type="accept" label="BMI Health Check">
  84.  
  85.         <go method="POST"  href="#results">
  86.  
  87.         <postfield name="h" value="$(height)"/>
  88.  
  89.         <postfield name="w" value="$(weight)"/>
  90.  
  91.         </go>
  92.  
  93.      </do>
  94.         <?php  /*  <anchor>
  95.      <go method="post" href="#results">
  96.        
  97.               <postfield name="h" value="$(height)"/>
  98.             <postfield name="w" value="$(weight)"/>
  99.                  </go>
  100.         Submit </anchor>                   
  101.            
  102. */?>
  103.                    
  104.  
  105.                    
  106.  
  107.                    
  108.  
  109.                 &nbsp;
  110.  
  111.                 &nbsp;&nbsp;
  112.  
  113.            
  114.  
  115. </p></card>
  116.  
  117.  
  118.  
  119. <card id="results" title="Your results">
  120.     <p>
  121.       Your weight is $(weight)kgs,<br/><br/>
  122.       your height is $(height)cm <br/><br/>
  123.       Your BMI is <?php
  124.              
  125.                     $link = @mysql_connect("localhost", "root", "" );
  126.  
  127.                     if (!$link) {
  128.  
  129.            die ('<p>Cannot connect to mysql</p>'. $close_card);
  130.  
  131.                     }
  132.  
  133.                     $h = ($_POST['h']);
  134.                     $w = ($_POST['w']);
  135.                     $bmi = ($w/(($h/100)*($h/100))) ;
  136.                    
  137.                     $bmi = round($bmi,2);
  138.                     if ($bmi < 18.5)
  139.                         $status = 'Underweight - You ';
  140.                    
  141.                     if ($bmi >=18.5 && $bmi < 24.9)
  142.                         $status = 'Normal';
  143.                        
  144.                     if ($bmi >= 24.9 && $bmi < 29.9)
  145.                         $status = 'Overweight';
  146.                    
  147.                        
  148.  
  149.                echo $bmi; ?>
  150.       Your status is: <?php echo $status; ?>      </i>.
  151.     </p>
  152. </card></wml>

Last edited by jabba_29 : February 28th, 2007 at 09:31 AM.

Reply With Quote
  #2  
Old February 28th, 2007, 09:10 AM
sunyukta sunyukta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 sunyukta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m
Reputation Power: 0
Talking oops...

well, that wasnt me using s word, thats just my name,
sunyukta...

Reply With Quote
  #3  
Old February 28th, 2007, 09:35 AM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,769 jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Weeks 6 Days 6 h 17 m 27 sec
Reputation Power: 1632
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
Hi sunyukta, welcome to Devshed.

I think it may be failing because you are printing out the second card
before the form has been posted....

You could try something like:
PHP Code:
<?php
if (!$_POST) {
// show form
} else {
// show results
print_r($_POST);
}

Also note that you WML output is invalid and will break on a real phone.
__________________
Cheers,

Jamie


# skiFFie | Home of the 'accessibility module' for Drupal
# Jamie Burns [me] Accessibility Module [drupal]
# guidelines | search | wap resources | not getting help | fold to cure


__________________

Let the might of your compassion arise to bring a quick end
to the flowing stream of the blood and tears .....
Please hear my anguished words of truth.



__________________

Reply With Quote
  #4  
Old March 1st, 2007, 11:38 PM
sunyukta sunyukta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 sunyukta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m
Reputation Power: 0
it works

hi , thanks...
im getting problems with $_POST[]...when im using postfield, say for a numeric field, when im using them in a query, im only getting the field name...

im posting some of my code
<?php
$conn_clinic = mysql_pconnect("localhost", "clinic", "") or trigger_error(mysql_error(),E_USER_ERROR);


mysql_select_db($database_conn_clinic, $conn_clinic);
$query_rsdept = "SELECT departments.Departmentno, departments.Departmentname FROM departments";
$rsdept = mysql_query($query_rsdept, $conn_clinic) or die(mysql_error());
$row_rsdept = mysql_fetch_assoc($rsdept);
$totalRows_rsdept = mysql_num_rows($rsdept);

function quote_smart($value)
{
// Stripslashes

if ( get_magic_quotes_gpc() )

{

$value = stripslashes( $value );

}

// Quote if not a number or a numeric string

if ( !is_numeric( $value ) )

{

$value = "'" . mysql_real_escape_string($value) . "'";

}

return $value;

}



// SET THE PAGE UP

header("Content-type: text/vnd.wap.wml");
echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "(URL address blocked: See forum rules)">
';

$search=<<<ASD
<table align="c" columns="2">
<tr>
<th ><strong>Doctor Name </strong></th>
<td ><strong>Speciality</strong></td>
<td ><strong>Email Address</strong></td>
<td ><strong>Phone Number</strong></td>
</tr>
ASD;

if (!$_POST) { ?>


<card id="main" title="MediCare Clinic"><p>

<template>
<do name="menu_1" type="accept" label="Home">
<go href="#menu_tc"/>
</do>
<do name="menu_2" type="accept" label="Log In ">
<go href="http://localhost/clic/login.php"/>
</do>
<do name="menu_3" type="accept" label="Find A Doctor">
<go href="http://localhost/FindADoc.php"/>
</do>
<do name="menu_4" type="accept" label="Make an appointment">
<go href="#makeapp"/>
</do>
<do name="menu_5" type="accept" label="Look up a medical term">
<go href="(URL address blocked: See forum rules)"/>
</do>
<do name="menu_6" type="accept" label="Health tools">
<go href="http://localhost/clic/bmi.php"/>
</do>
<do name="menu_7" type="accept" label="About Medi Care Clinic">
<go href="contact.wml"/>
</do>
<do name="menu_8" type="accept" label="Contact Us">
<go href="contactus.wml"/>
</do>

</template>


<do type="prev" name="prev" label="Go Back"><prev/></do>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>&nbsp;
&nbsp;&nbsp;&nbsp;</strong>&nbsp;&nbsp;
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Find A Doctor</p>




<p> You can find out about our doctors in this page.
You will get their email addresses and office phone numbers.


&nbsp;&nbsp;

&nbsp;
<p>Search by Department:
<select name="dept" id="dept" emptyok="false">
<?php
do {
?>
<option value="<?php echo $row_rsdept['Departmentno']?>"<?php if (!(strcmp($row_rsdept['Departmentno'], $row_rsdept['Departmentno']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsdept['Departmentname']?></option>
<?php
} while ($row_rsdept = mysql_fetch_assoc($rsdept));
$rows = mysql_num_rows($rsdept);
if($rows > 0) {
mysql_data_seek($rsdept, 0);
$row_rsdept = mysql_fetch_assoc($rsdept);
}
?>
</select>&nbsp;
<p> Name: &nbsp;

&nbsp;


<p>

<anchor>
<go method="POST" href="http://localhost/clic/FindADoc.php#results">


<postfield name="dept" value="$(dept)"/>
</go>
Search </anchor>

<anchor>
<do type="reset" label="Reset">
<refresh>

<setvar name="dept" value=""/>
</refresh>
&nbsp;&nbsp;&nbsp;&nbsp;Reset
</do>
</anchor>

<a href="http://localhost/clic/clinicrecent.php" >Go Back</a>

</p>
</card>



<card id="results" title="Results" >
<?php
}

if ($_POST) {

//echo "<p>Invalid operation"."<a href=\"history.back()\" >Go Back</a>";


$close_card = '</card>
</wml>';

$deptid = $_POST['dept'];

if (!empty($deptid)) {

$sql = "SELECT * FROM doctor INNER JOIN staff ON doctor.EmployeeID = staff.Employeeid WHERE staff.Departmentno =$deptid"; This query doesnt work
print($sql);
$result = mysql_query($sql);


if (@mysql_num_rows($result)==0)
echo "<p>No records found"."<a href=\"http://localhost/FindADoc.php\" >Go Back</a>";



else {
// show each doctor's record, with details. to complete

while($row=@mysql_fetch_array($result))
{
$search.="
<tr>
<td>".$row["Employeefname"]. " " .$row["Employeelname"]."</td>
<td>".$row["Speciality"]."</td>
<td><a href=\"mailto:".$row["email"]."\">".$row["email"]."</a></td>
<td>".$row["Phone1"]."</td>
</tr>";
}
$search.="</table>";

echo $search;
echo $close_card;
}//else
}//else


echo $close_card;
}
?>
<?php
mysql_free_result($rsdept);
?>

iv used a recordset which prints all the options for departments, it's supposed to print details about staff when i click on search.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreMobile Programming > Passing $_POST data with postfield (was: Hi...desperately need help)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off