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
251
14
Other php-forum
Add 5 to a variable when a button is clicked, and re-run a for loop
So I'm making a feedback sort of section on a website with MySQL and PHP, I've gotten the script to
Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h
modifying query string with no page refresh
Hi everybody,
I've tried to get info about my problem all over the internet but i didn't find out
login page does not execute a else statement
I've created a login page using sessions.
When an incorrect user name or password is entered then
Access website from only 1 computer...?
One of my customers wants his website to only be accessed by people in which they bought the website
Last Weeks sDate and eDate.
sDate - Start Date
eDate - End Date
I need to pull two dates for "Last Week" whi
Change Web page language
i doing this thing first time but i dont find any suitable solution for it. On the demand of user. I
Creating an invoice
Using fpdf I am trying to create an invoice to send to clients. The products are sold in pricing tie
Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of
image upload script not working with png
The basic process of this php code is to take the submitted file, convert it to a small JPG thumbnai