Page 1 of 1

Php Form

Posted: Sun Aug 06, 2006 10:48 pm
by Digeart
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a form which people fill out details and click send. What happens, is depending on the details an email is sent to a different person.

The concerning variables in my form are:

'$publication' a series of checkboxes which are North, South and Bayside.

'$photo_for' which is also a series of checkboxes with the values of Advertisment, Editorial, Advertorial, Window Shop, Designers Feature.

Here is the break down of options for who the form gets sent to:

Code: Select all

Ricky (myself): North (Advertisment, Editorial, Advertorial, Window Shop, Designers Feature) - Everything
                       South (Editorial) - Only Editorial

Desired Creations: Bayside (Advertisment, Editorial, Advertorial, Window Shop, Designers Feature) - Everything
                             South (Advertisment, Editorial, Advertorial, Window Shop, Designers Feature) - Everything
This is the code I had:

Code: Select all

if (in_array('North',$publication) || (in_array('South',$publication) && in_array('Editorial',$photo_for))){
		$photographer = "Ricky Sullivan <ricky@stylemagazines.com.au>";
} else {
		$photographer = "Desired Creations <admin@desiredcreations.com.au>";
}
But what's happening is when some one chooses Editorial and Advertisement (or anything else) for the South, the form comes to me.

If there was a way to make it say

(in_array('South',$publication) && $photo_for == 'Editorial'))

I think its because its an array. Whats a good way to sort this?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Aug 06, 2006 10:55 pm
by volka
Digeart wrote:South (Editorial) - Only Editorial
means: no other checkbox is checked?
Then this array should only contain one element -> count()

Posted: Sun Aug 06, 2006 10:55 pm
by feyd

Code: Select all

&& count($photo_for) == 1
maybe?

Posted: Sun Aug 06, 2006 11:01 pm
by Digeart
volka wrote:
Digeart wrote:South (Editorial) - Only Editorial
means: no other checkbox is checked?
Then this array should only contain one element -> count()
But it can only be "Editorial" that is checked. that rules out the possibility.

If only "Advertisment" was checked the count will also be 1, therefore sending the email to me.

Posted: Mon Aug 07, 2006 12:08 am
by volka
Take a closer look at feyd's post, esp. the &&