Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cotacts page with checkbox

Status
Not open for further replies.

McFestoe

Technical User
Dec 16, 2003
145
GB
Hi all

Is there a way to have a checkbox on a contacts form that alters the email address the form is sent to, like if button A is selected the email address A is used or button B is selected thean email address B is used.

Thanks

 
Sure there is, on the processing page simply add an if sentence that checks the value of the checkbox and proceeds accordingly.
 
Just learning PHP, sorry to ask where would the processing page be?

Thanks

 
The "processing page" is simply the PHP file you specify as the "action" of your form. Have something like this in your form:
Code:
<form action="process.php" method="post">
<input type="checkbox" name="send2b">Send the mail to Mr. B
<textbox name="message"></textbox>
etc.
Then in process.php, have something like this:
Code:
if ($_POST['send2b']) {
  $to = "b@mydomain.com";
} else {
  $to = "a@mydomain.com";
}
mail($to,"Form message from web site",$_POST['message']);
Does that help?
 
Thanks for the reply.

Does this bit of script put a check box on the form

<form action="process.php" method="post">
<input type="checkbox" name="send2b">Send the mail to Mr. B
<textbox name="message"></textbox>
etc.

I think it get this bit, if the check box is selected then send mail to Mr. B , the textbox name is that what is displayed on the screen.

Is it possible to have a two checkboxes (like toggle buttons in access) that one is always the default value and if the other one is selected then it changes.

Many thanks again for the replies, iam slowly learning..
 
Looks like you need some good tutorials in HTML, too. The form element is <textarea>, not <textbox>.

As well, if you want someone to make an exclusive choice, where ONLY one item of a set can be chosen, you should use radio buttons rather than checkboxes, and use the same name for all these radio buttons.

Lee
 
You might find this page helpfull, with the creation of forms. Once you get the creation of forms down, then we can explain how to interact with them from PHP.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for the advice and that link, just the site i need, gone to find out more and will post a link to what i manage.

Thanks Guys.
 
Very welcome.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
trollacious said:
The form element is <textarea>, not <textbox>.
Oops - thats what I get for trying to write at 1 a.m.!

McFestoe, it looks like the other folks took good care of you while I slept. I didn't realize you were not only a newbie to PHP but to HTML as well. Definitely, at your stage of learning, the online tutorials and manuals are your first and best resource (or even printed books - sometimes I like having the reference in my lap). For PHP, try For HTML, there are a zillion good sites - w3schools is one that is very accurate, but if it gets too technical for you at first, try looking for something more user-friendly, like or a host of others. Welcome to the web design community!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top