You are here: Re: Testing if two fields have data in them « PHP Programming Language « IT news, forums, messages
Re: Testing if two fields have data in them

Posted by Jerry Stuckle on 11/19/53 11:45

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
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация