Why is this function returning a false value when it shouldn't be??
Posted on
16th Feb 2014 07:03 pm by
admin
This is in an include file. I want it to check a value in an html form and see if it's just white space, is numbers, is empty etc.
Code: (text) [Select]<?php
function checkString($stringFieldName,$_GET){
$output="n<p> ";
$validate=true;
if(array_key_exists($stringFieldName,$_GET))
{
//trim any whitespace from values
$string=trim($_GET[$stringFieldName]);
//check if string value is empty
if(empty($string)){
$output.="nYou haven't entered any data in string<br />";
$validate=false;
}
if(is_numeric($string)){
$validate=false;
$output.="You have entered a number instead of text";
}
//if they have deleted values from url
}else{
$output.="nYou have deleted the characters from the urln";
$validate=false;
}
echo $output."n</p>";
}
I am using it in a php file, the code is here:
Code: (text) [Select]
<?php
echo "n<p>";
include 'validateText&Number.inc';
checkString("surname",$_GET);
if ($validate==false){
echo "nYou did not enter the name correctly.";
}
else.................
{When I type in actual text it tells me I have not entered name correctly which therefore means $validate must be false. I don't know how though it can be set to false because if the field just contains text, it isn't satisfying any of the conditions that lead to $validate=false.
Please help!! Oh I'm a php newbie btw
No comments posted yet
Your Answer:
Login to answer
251
14
Other forums
default SAP userid
hi,, I just like to know if it is ok to use the default SAP user id (SAP*)?
Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate w
How to display random record from table?
I have the following code:
Code: <?php
$display_block .= "<input type=
PHP Redirecting
Hello everyone. Is there a way to redirect people to pages within a statement in PHP? Since there is
A rank users order by points
I want to make an insert from table 'rank' , with number (rank) from the cod blow, to fild users.ran
utl_file open error
i have file in the unix path
Path /popdev01/pop/popdevb/tfi/
File name
DBCA Templates
Hi all,
I'm working on creating a template for DBCA, but can't find any documentation on the
Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like
Need help in Generating Combinations
Need help generating all possible combination of names in an array
Lets say i have the follow
Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:
-Da