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 Like 14 Dislike
Previous forums Next forums
Other forums

Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in

Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.

What I'm doin

xml
<?php

echo "<h1>XML Articles</h1>";

$home

PHP Thumbnail Creation
Ok so i use this function to create thumbnails:

Code: function createthumb($name,$filename,$n

Posting to another Site?
I have software that people install.
When they install it, is there a way to make it post their d

mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id

Varible in trigger - refering to correct schema
Hello

Im having some issues with my trigger.
What I want to do is call opon a differ

PHP hyperlinks generator
Hi

I need some help to get this done using php:


1 - I have few hyperlinks say 500

Find only certain URLs from page ... regex (semi-complete script)
Hi guys,

What I need to do is take a page & extract all the URLs from the page &a

iMatch stored value with the current value in a loop
Hello,

I have a MySQL db were I store articles in.

I have a form to fill these article

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash