Forum Moderators: coopster

Message Too Old, No Replies

check box from form to php

         

Kysmiley

10:14 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



I have one check box in a form, depending on if the box is checked a message is included in the email from the rest of the form.
I have done a search on here and in the PHP manual and dont seem to find what Im looking for. Can someone point me in the correct direct to learn what and how to include it in my suggestion box script.
Pat

IanKelley

10:28 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your question is a little unclear, you say that you have a script which does something and then you seem to ask how to make it do it :-)

Does your script already have the checkbox and the logic to email if checked and you're having problems with the code?

Or have you not written any of it and you're trying to figure out how to go about it?

Kysmiley

10:41 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



I have a script and it is working finaly, but I have one check box in it that lets the visiter check it if they want to be contacted. This form is sent to me with all the comments and information yet I'm not sure how to also get the part from the check box included it it is checked.
like
if (checked_box = checked) include this line in email
else (dont)
sworry thats the best way I can think of e3xplaining it
Pat

Salsa

12:08 am on Nov 27, 2004 (gmt 0)

10+ Year Member



The value attribute of your checkbox is what you are going to be looking for in the receiving script. In your form you might have:

<input type="checkbox" name="whatever" value="1">

In your receiving script, however, $_POST['whatever'] will have a value of "1" only if the checkbox is checked. So you would need:

if ($_POST['whatever'] == 1) // include this line in email

Kysmiley

12:31 am on Nov 27, 2004 (gmt 0)

10+ Year Member



thank-you salsa I was putting the ==1 inside the [] I also neglected to put the value = 1 in the form
got to love this forum for their expertice
Pat

dcrombie

11:47 am on Nov 27, 2004 (gmt 0)



If you leave out the "value=1" then the $_POST variable will have a value of "on".