Laguna Posted April 25, 2007 Share Posted April 25, 2007 Why is it not validating ?? <form id="form1" name="form1" method="post" action="DiagnosisSoup.php"> <div align="center">Temeprature <label> <input type="text" name="temp" /> </label> <p> <label> <input type="checkbox" name="running_nose" value="checkbox" /> Running nose</label> </p> <p> <label> <input type="submit" name="submitted" value="Submit" /> </label> </p> </div> </form> <? //if the form is submitted, process user input if (isset($_POST['submitted'])) { //verify user input $result = true; if (is_numeric($_POST['temp'])) { echo "Temperature should be numeric"; $ready = false; } //check as many conditions as you like if ($_POST['temp']>42 || $_POST['temp']<30) { echo "You should be dead by now."; $ready = false; } //if all's well, process data if ($ready) { if ($_POST['temp']>37.5 && isset($_POST['running_nose'])) echo "You probably have cold."; } else DrawForm(); //data wasn't validated, so draw the form once again } else //form isn't submitted yet, so draw the form { DrawForm(); } function DrawForm() { include'testdiagnosis.php'; } ?> can anyone help ?? Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted April 25, 2007 Share Posted April 25, 2007 what is the value of the temp input? Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 25, 2007 Author Share Posted April 25, 2007 i put in 42 for the input and it says Tempature should be numeric how come 42 is not numeric ?? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 25, 2007 Author Share Posted April 25, 2007 double post sorry Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted April 25, 2007 Share Posted April 25, 2007 Change it to this and tell me what happens: <form id="form1" name="form1" method="post" action="DiagnosisSoup.php"> <div align="center">Temeprature <label> <input type="text" name="temp" value="42"/> </label> <p> <label> <input type="checkbox" name="running_nose" value="checkbox" /> Running nose</label> </p> <p> <label> <input type="submit" name="submitted" value="Submit" /> </label> </p> </div> </form> Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 25, 2007 Author Share Posted April 25, 2007 Change it to this and tell me what happens: <form id="form1" name="form1" method="post" action="DiagnosisSoup.php"> <div align="center">Temeprature <label> <input type="text" name="temp" value="42"/> </label> <p> <label> <input type="checkbox" name="running_nose" value="checkbox" /> Running nose</label> </p> <p> <label> <input type="submit" name="submitted" value="Submit" /> </label> </p> </div> </form> it still says temperature is numeric Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 26, 2007 Author Share Posted April 26, 2007 Can anyone tell me why when put in numbers it still says temperature is numeric ?? Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted April 26, 2007 Share Posted April 26, 2007 post the DiagnosisSoup.php page code up please. Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 26, 2007 Author Share Posted April 26, 2007 post the DiagnosisSoup.php page code up please. <? //if the form is submitted, process user input if (isset($_POST['submitted'])) { //verify user input $result = true; if (is_numeric($_POST['temp'])) { echo "Temperature should be numeric"; $ready = false; } //check as many conditions as you like if ($_POST['temp']>42 || $_POST['temp']<30) { echo "You should be dead by now."; $ready = false; } //if all's well, process data if ($ready) { if ($_POST['temp']>37.5 && isset($_POST['running_nose'])) echo "You probably have cold."; } else DrawForm(); //data wasn't validated, so draw the form once again } else //form isn't submitted yet, so draw the form { DrawForm(); } function DrawForm() { include'testdiagnosis.php'; } ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 26, 2007 Share Posted April 26, 2007 this code here if (is_numeric($_POST['temp'])) { echo "Temperature should be numeric"; $ready = false; } if $_POST['temp'] is a number it will echo out 'Temperature should be numeric' change it to if (!is_numeric($_POST['temp'])) { echo "Temperature should be numeric"; $ready = false; } Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 27, 2007 Author Share Posted April 27, 2007 oo i know i miss the if (!is_numeric($_POST['temp'])) { echo "Temperature should be numeric"; $ready = false; } but the problem is now it doesnt run this statement if ($ready) { if ($_POST['temp']>37.5 && isset($_POST['running_nose'])) echo "You probably have cold."; } must i declare $ready ?? Quote Link to comment Share on other sites More sharing options...
Laguna Posted April 27, 2007 Author Share Posted April 27, 2007 double post sorry Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.