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){
Did you know?Explore Trending and Topic pages for more stories like this.
$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
webpage with (simple) login & mysql-db
Hi all,
What I was looking for before was a multi-user password manager, web-based! The offer
mysql_real_escape_string making variable equal nothing
i post a form and i post the variable:
Code: $var = $_POST[variable];then i echo $var its what i
noob cURL help
I have a pretty basic form that I need to cURL post to a file in my includes folder (includes/login.
frame help
on the bottom frame is menu.html
Code: <body><form action='link.php' met
with clause
hi all, i have a big query that usually access the same table more than once. for example, i have s
how to remove in php string display
My code is
$message="We're looking at developing our website.";
$body= "
Is there a more efficient way to code this than what I have?
I have three associative arrays.
$combinedSettings
$userSettings
$defaultSettings
server trace logs
could any one tell me from where do i get error logs in xMII??I want to check the reason for dtabase
Add User script "Could not execute query"
This should be an easy script but I can't get it to run. Can someone please help me?
<
curl javascript problem
Hi Experts.
I'm new curl and wanna to get some info from this http://www.amadeus.net/
when