Hi
I am a newbie and struggling with my guestbook validation process.
I have found the following function online to check the length of a
form field.
<?php
function checkLength($st ring, $min, $max) {
$length = strlen ($string);
if (($length < $min) || ($length > $max)) {
return FALSE;
} else {
return TRUE;
}
}
?>
Now below is the area in my code where I have to fit what that function
returns but I can't do it. The "Text" field is the one that has to be
checked for a certain length (Like $min = 1, $max = 100).I would like
to point to the error.html file if checkLength returns false.
$Text = $_POST['Text'] ;
$email = $_POST['email'] ;
$name = $_POST['name'] ;
if (empty($name) || empty($email)) {
header( "Location: error.html" );
}
else
{
//The fields are entered in the database here if it all goes fine.
Thanks a lot
Patrick 8 1702
varois83 wrote: Now below is the area in my code where I have to fit what that function returns but I can't do it. The "Text" field is the one that has to be checked for a certain length (Like $min = 1, $max = 100).I would like to point to the error.html file if checkLength returns false.
$Text = $_POST['Text'] ; $email = $_POST['email'] ; $name = $_POST['name'] ;
if (empty($name) || empty($email)) { header( "Location: error.html" );
if (!checkLength($ Text, 1, 100) || empty($name) || empty($email)) {
....
}
BTW, there's more to form validation than used in this code (per example, it
will allow a single white space character to pass as a valid email address),
but you will probably get to this when you have learned more about PHP.
JW
I noticed that Message-ID: <41************ **********@news .euronet.nl>
from Janwillem Borleffs contained the following: if (!checkLength($ Text, 1, 100) || empty($name) || empty($email)) {
Bit unfriendly sending people to an error page if they type too much.
Still I suppose you have your reasons. Consider using some Javascript
in addition to the PHP code to give the user instant feedback that they
are over the limit
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
On Sun, 23 Jan 2005 23:14:54 +0000, Geoff Berrow <bl@ckdog.co.uk > wrote: I noticed that Message-ID: <41************ **********@news .euronet.nl> from Janwillem Borleffs contained the following:
if (!checkLength($ Text, 1, 100) || empty($name) || empty($email)) {
Bit unfriendly sending people to an error page if they type too much. Still I suppose you have your reasons. Consider using some Javascript in addition to the PHP code to give the user instant feedback that they are over the limit
Or the maxlength attribute if it's an <input>. Shame there isn't such an
attribute on <textarea> though.
--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Hi
JB
God I tried everything for 2 hours, it's almost not fair.A pair of
parenthesis did me in.
Look at what I had that came the closest.:
if (empty($name) || empty($email) || (!checkLength($ Text, 1, 100))) {
I also understand that there is a lot more to validation than that but
practice will make perfect.
Thanks so much for your help JB it's working now.
Geoff
Bit unfriendly sending people to an error page if they type too much.
Still I suppose you have your reasons. Consider using some Javascript
in addition to the PHP code to give the user instant feedback that they
are over the limit.
Just playing around with the code at this time Geoff, trying to use
only PHP at this point. I am going to create a page that tells people
that use more than 100 characters not to do so.
Thanks a lot guys
Patrick
JW
I spoke too fast in my previous post and tested what you said about the
code allowing a single space. It did!
How do you fix that?
Thanks again
Patrick
varois83 wrote: JW
I spoke too fast in my previous post and tested what you said about the code allowing a single space. It did! How do you fix that?
Thanks again
Patrick
regular expressions
Thanks again guys will get on it right away.
Patrick This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
OK:
Purpose: Using user's input and 3 recursive functions, construct an hour
glass figure. Main can only have user input, loops and function calls.
Recursive function 1 takes input and displays a sequence of spaces;
recursive function 2 uses input to display ascending sequence of digits;
likewise, recursive function 3 uses input to display descending sequence of
digits.
I have not followed the instructions completely regarding the...
|
by: Marek Lewczuk |
last post by:
Hello,
I'm moving out from MySQL to PostgreSQL and there are some function
which are not supported in PG so I'm trying to write my own functions.
Currently I have big problem with function IF(), below the description
of this function from MySQL manual.
Anybody can help me with this ?? I think that PLPGSQL language can be
used or maybe other (plPerl) etc.
|
by: Tweaxor |
last post by:
Hey,
I was trying to figure out was it possible in C to pass the values in an array
from one function to another function. Is the possible in C?
ex. y is the array that holds seven values
If possible how could one pass these seven values in the array
to a function that would check the values.
I tried return y but it didn't work
|
by: Marco Loskamp |
last post by:
Dear list,
I'm trying to dynamically generate functions; it seems that what I
really want is beyond C itself, but I'd like to be confirmed here.
In the minimal example below, I'd like to create content to put at
the address pointed to by f. In particular, I'd like to avoid/replace
the memcpy line.
Possible application (inspired by Paul Graham, "ANSI Common Lisp",
|
by: Razzel |
last post by:
I created this as a test:
#include <time.h>
main(){
printf(X1: %s\n", putim());
printf(X2: %s\n", putim());
}
putim() {
time_t t;
time(&t);
return(ctime(&t));
| |
by: ranjmis |
last post by:
Hi all,
I have come across a piece of code wherein a function returns a
function pointer as it seems to me but not very clear from the
prototype.
As shown below - although return type is void - (*master())() returns a
function pointer some_func & meanwhile calls that function and prints
the message "hi from some_func"
|
by: mosesdinakaran |
last post by:
Hi everybody,
Today I faced a problem where I am very confused and I could not
solve it and I am posting here....
My question is
Is is possible to return a value to a particular function
The question may be silly or even meaning less but
please............
|
by: jknaty |
last post by:
I'm trying to create a function that splits up a column by spaces, and
I thought creating a function that finds the spaces with CHARINDEX and
then SUBSTRING on those values would an approach. I get an error
saying that the I have an Invalid column 'Course_Number'. Not sure
why but I am very new to User Defined Functions. Here is what I have
so far:
CREATE FUNCTION CourseEvalBreakdown
(
|
by: Antoninus Twink |
last post by:
What's the correct syntax to define a function that returns a pointer to
a function? Specifically, I'd like a function that takes an int, and
returns a pointer to a function that takes an int and returns a string.
I tried this:
gchar *(*f(gint n))(gint)
{
/* logic here */
}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |