Php Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Digeart
Forum Newbie
Posts: 7
Joined: Wed Mar 03, 2004 8:47 am

Php Form

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Digeart wrote:South (Editorial) - Only Editorial
means: no other checkbox is checked?
Then this array should only contain one element -> count()
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

&& count($photo_for) == 1
maybe?
Digeart
Forum Newbie
Posts: 7
Joined: Wed Mar 03, 2004 8:47 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Take a closer look at feyd's post, esp. the &&
Post Reply