Testing if two fields have data in them

This is a discussion on Testing if two fields have data in them within the PHP Language forums, part of the PHP Programming Forums category; Geoff Berrow wrote: > Message-ID: <SQy1g.55760$Nh7.17628@newsfe4-win.ntli.net> from Ian > Davies ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-20-2006
Rik
 
Posts: n/a
Default Re: Testing if two fields have data in them

Geoff Berrow wrote:
> Message-ID: <SQy1g.55760$Nh7.17628@newsfe4-win.ntli.net> from Ian
> Davies contained the following:
>
>> if(isset($_POST['Link'] && isset($_POST['uploadedfile'])){

>
> isset will return true for certain form elements even if they are
> empty.
>
> Assuming the elements are not checkboxes radio boxes or buttons, try
>
> if(!empty($_POST['Link']) && !empty($_POST['uploadedfile'])){
> ...
>
>
> If this doesn't work, let us know what elements you are dealing with.


A simple print_r($_POST) would clarify a lot....
Enough working examples in this thread.

If the current examples don't work, $_POST['uploadedfile'] makes me suspect
the $_FILES array should by checked....

Grtz,
--
Rik Wasmus


Reply With Quote
  #12 (permalink)  
Old 04-20-2006
Rik
 
Posts: n/a
Default Re: Testing if two fields have data in them

Rik wrote:
> If the current examples don't work, $_POST['uploadedfile'] makes me
> suspect the $_FILES array should by checked....


D'ok, that answer was already giiven.
Refreshing the ng after browsing for a while can save a lot of time :-)

Grtz,
--
Rik


Reply With Quote
  #13 (permalink)  
Old 04-20-2006
Ian Davies
 
Posts: n/a
Default Re: Testing if two fields have data in them

Cheers Geoff
That was it

Ian

"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:7oie425ns6m4p50up8qj2lbgtjc3nbr2vl@4ax.com...
> Message-ID: <FTH1g.36888$zf1.12352@newsfe5-gui.ntli.net> from Ian Davies
> contained the following:
>
> >The first option the user browses for their file and it is submitted via
> >type=file

>
> Ah...
>
> if(!empty($_POST['Link']) && !empty($_FILES['uploadedfile'])){
> ...
> --
> 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/



Reply With Quote
  #14 (permalink)  
Old 04-20-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Testing if two fields have data in them

Ian Davies wrote:
> Hi
> The problem is that the alternative runs even when it shouldnt. The code
> should be such that if the the two fields have something in them then an
> error should be produced.
>
> Let me expand on what Im trying to do
> I wish the users to either to upload a file to my website or as an
> alternative send a link to their website which is added to a table in my
> database.
> The first option the user browses for their file and it is submitted via
> type=file
> The second option uses type=text
>
> What I wish to do is to stop user from putting data into both fields
> I want the code to test the submitted data and if text field and file field
> have something in them then a message would say 'You cant submit a link and
> a file at the same time'
>
> To see what Im trying to acheive go to
> http://www.iddsoftware.co.uk/Resources.php
>
> Thanks
> Ian
>
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:J6ydnenpLZgrY9vZRVn-ug@comcast.com...
>
>>Ian Davies wrote:
>>
>>>Thanks Gordon
>>>Unfortunately your solution does not work. It allows the 'else' part of

>
> the
>
>>>code to proceed
>>>
>>>Ian
>>>
>>>"Gordon Burditt" <gordonb.lkgz9@burditt.org> wrote in message
>>>news:124df97s3t7rr2a@corp.supernews.com...
>>>
>>>
>>>>>Im trying to test if two fields have been entered at the same time
>>>>>I have tried many combinations but cant get it. My last effort was
>>>>>
>>>>>
>>>>>if(isset($_POST['Link'] && isset($_POST['uploadedfile'])){
>>>>>die('You can\'t select to upload a link and a file at the same time.');
>>>>>}
>>>>>else
>>>>>{
>>>>>STUFF HERE;
>>>>>}
>>>>>
>>>>>but still cant get it to work
>>>>>
>>>>>Help appreciated
>>>>
>>>>So what happens when you try? It gives you the error when it shouldn't,
>>>>or it doesn't give you the error when it should?
>>>>
>>>>A blank field is not the same as NO field. I'm going to guess
>>>>that you mean:
>>>>
>>>>if ((isset($_POST['Link']) && $_POST['Link'] != '')
>>>> && (isset($_POST['uploadedfile']) && $_POST['uploadedfile'] != '') {
>>>>
>>>>Gordon L. Burditt
>>>
>>>
>>>

>>
>>But if the condition is false, the else clause SHOULD run. What's the

>
> problem?
>
>>--
>>==================
>>Remove the "x" from my email address
>>Jerry Stuckle
>>JDS Computer Training Corp.
>>jstucklex@attglobal.net
>>==================

>
>
>


Personally, I would have just put the two fields in two different forms, each
with its own submit button. Both can be submitted to the same page; just give
the buttons different names.

It's also more obvious that you're looking for one OR the other.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0