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
classic dynpro : hide area and auto adjust hights
Hi,
I want to develop a similar user interface as is used in standard transaction MIGO.
Typing math
I've added support for typesetting math using LaTeX on the forums.
Example:
Code: [Select]
Splitting Attributes
SQL> SELECT I_NAME, substr(I_NAME,1,instr(I_NAME,'O')) "First part",
substr(I_NAME, IN
Wordpress IE issue
So I am trying to add the background shadow to my wordpress page. It works fine in Firefox but does
Take info from one coloum and move to another
Hi all,
I have this:
Code: [Select]$array = "SELECT stock_id FROM stocks WHERE stock_
Oracle Connectivity
Hi Every One,
Can we access SAP from oracle database.If it possible then please spec
PECL uploadprogress for php5.2
Hey, I just installed PHP5 via .htaccess on my 1and1 Shared Hosting Account.
How would I exac
Number Format
Hi All,
I have number '000000000050085' I want to format it to 500.85 Can any one give me
Need help Updating SQL Server Express DB from c# :(
Please can anyone help with:-
1 How to sructure the strSelect statement.
2 How to instruct
Simple program to copy files between two computers over the web
I use logmein free and often need to move files between my two computers. Generally, I move the file