473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Form validation

I am a newbie to PHP and finding even the simple stuff quite hard.

I am trying to validate an email address using a recursive page.

The validation is done using a regular expression which works fine , and the
valid/invalid messages shows as expected.

My input tag is as follows:
<input type="text" name="emailAddress" value="<?php
$HTTP_POST_VARS['emailAddress'] ?>">

When the page refreshes the input field is blank!

How do retain the value typed?

TIA

Roger

Jul 17 '05 #1
6 2851
On Fri, 6 Feb 2004 23:53:09 +0000 (UTC), Roger Price
<ro*********@btinternet.com> wrote:
I am a newbie to PHP and finding even the simple stuff quite hard.

I am trying to validate an email address using a recursive page.

The validation is done using a regular expression which works fine , and the
valid/invalid messages shows as expected.

My input tag is as follows:
<input type="text" name="emailAddress" value="<?php
$HTTP_POST_VARS['emailAddress'] ?>">

When the page refreshes the input field is blank!

How do retain the value typed?


You have:

<?php $HTTP_POST_VARS['emailAddress'] ?>

This does nothing. You probably mean:

<?php echo htmlentities($_POST['emailAddress']); ?>
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2
do this:

<input type="text" name="emailAddress" value="<? echo
$HTTP_POST_VARS['emailAddress']; ?>">
--
"Roger Price" <ro*********@btinternet.com> wrote in message
news:BC49D964.FE34%ro*********@btinternet.com...
I am a newbie to PHP and finding even the simple stuff quite hard.

I am trying to validate an email address using a recursive page.

The validation is done using a regular expression which works fine , and the valid/invalid messages shows as expected.

My input tag is as follows:
<input type="text" name="emailAddress" value="<?php
$HTTP_POST_VARS['emailAddress'] ?>">

When the page refreshes the input field is blank!

How do retain the value typed?

TIA

Roger

Jul 17 '05 #3
Hi thanks for that which solves the question I asked. However when the page
is requested for the first time the input field displays:

<br /><b>Notice</b>: Undefined index: emailAddress in
<b>d:\inetpub\wwwroot\Projects\group13\email.php </b> on line
<b>50</b><br />

Please do you have any suggestions?

Roger

in article VG********************@news20.bellglobal.com, Yang Li Ke at
ya******@sympatico.ca wrote on 7/2/04 2:02 am:
do this:

<input type="text" name="emailAddress" value="<? echo
$HTTP_POST_VARS['emailAddress']; ?>">
--
"Roger Price" <ro*********@btinternet.com> wrote in message
news:BC49D964.FE34%ro*********@btinternet.com...
I am a newbie to PHP and finding even the simple stuff quite hard.

I am trying to validate an email address using a recursive page.

The validation is done using a regular expression which works fine , and

the
valid/invalid messages shows as expected.

My input tag is as follows:
<input type="text" name="emailAddress" value="<?php
$HTTP_POST_VARS['emailAddress'] ?>">

When the page refreshes the input field is blank!

How do retain the value typed?

TIA

Roger


Jul 17 '05 #4
> Hi thanks for that which solves the question I asked. However when the
page
is requested for the first time the input field displays:

<br /><b>Notice</b>: Undefined index: emailAddress in
<b>d:\inetpub\wwwroot\Projects\group13\email.php </b> on line
<b>50</b><br />

Please do you have any suggestions?


<input type="text" name="emailAddress" value="<? if (isset
($HTTP_POST_VARS['emailAddress']; )){echo $HTTP_POST_VARS['emailAddress']};
?>">
Jul 17 '05 #5
Hi Filth (interesting name!)

It never occurred to me that it was possible to include a conditional inside
an attribute value. You can learn so much that they never show you in the
books on lists like this.

The code did not work first time as the ";" did not seem to be in the
correct place!

The following worked though:

<input type="text" name="emailAddress" value="<?php if (isset
($HTTP_POST_VARS['emailAddress'] )){echo $HTTP_POST_VARS['emailAddress'];}
?>">

The web server is IIS 5.0 which does not seem to like the "<?=...?>
shortened form so "<?php" works better.

Thank you

Roger
--

Roger Price

Email: ro*********@btinternet.com

in article PY****************@news-binary.blueyonder.co.uk, Filth at
p.*********@blueyonder.co.uk wrote on 7/2/04 4:00 pm:

<input type="text" name="emailAddress" value="<? if (isset
($HTTP_POST_VARS['emailAddress']; )){echo $HTTP_POST_VARS['emailAddress']};
?>">


Jul 17 '05 #6
<input type="text" name="emailAddress" value="<?php if (isset
($HTTP_POST_VARS['emailAddress'] )){echo $HTTP_POST_VARS['emailAddress'];}
?>">

The web server is IIS 5.0 which does not seem to like the "<?=...?>
shortened form so "<?php" works better.


Doh!!! thats what happens when you cut and paste forgot to delete the ;, you
should always use <?php as it works on all set ups <? doesnt amongst several
other variations.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
4
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
5
by: lucyh3h | last post by:
Hi, I am trying to use XMLHttpRequest to do server side validation. I have several fields on a form and a submit button. The submit button has an event assocated with it when clicked. The...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.