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
PHP Directory Listing Not working
Hey Guys,I need help, I tried a ton of directory listing scripts and they all don't work. Althogh the normal Apache Directory Indexing does work when you visit. The URL is
How would I protect......
I have a from, actually, a good amount of forms. How can I make it so you can't type the characters: '!~*&^%().;-_ in the form? Where it completely blocks those characters
Need help with a mail notify function
I was tasked with setting up a site that's been prewritten. The site is basically a form that captures user's info on the frontpage. All the code is there except the ability to notify the admin upon
Just wondering what you think about my site
I am new to phpfreaks i just seen this form and thought it would be cool to see what other thought about my site, feel free to sign up an post items to see how that all works or if you dont want to
explode() function problem maybe
Hi I'm having trouble searching my database. When I type two words in the search field it only searches for the second word. For example: if I typed london zoo , it will only search for zoo.Is this
Career Change into SAP
Hai
Hyperlink is adding an extra gap to variable
Hi, here's my problem..I have a php generated page with a hyperlink which opens in a new windowecho "<tr><td><a
Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doing for the last few weeks. Basically I have searched the web, high and low for a "mail to a
Session
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not have any trouble logging into forums such at these, so not sure why this is not working.first the
natcasesort works on one server but not on another
HiI have a problem that I was hoping that someone can help me with.I'm trying to use natcasesort() to sort an array. This works fine on my laptop (which I use for testing and which uses php 5.2.6),