Page 1 of 1

help please with this form broblem

Posted: Sat Nov 20, 2004 1:59 pm
by Syrman
Hello all

I have the following form

<FORM METHOD="POST" ACTION="">
<input name="checkbox" type="checkbox" value="checkbox" checked>
test1
<input name="checkbox2" type="checkbox" value="checkbox" checked>
test2
<INPUT NAME="name" TYPE=text id="name">
<INPUT NAME="email" TYPE=text id="email">
<INPUT NAME="city" TYPE=text id="city">
<INPUT name="submit" TYPE=submit id="Submt" VALUE="submit;">


which contains two checkboxes and other information, the problem I want to store the values entered by the user in three different text file.

1- If the user chose the first checkbox and enter his/her information the code will store the values to text a.

2- If the user chose the second checkbox and enter his/her information the code will store the values to text b.

3- If the user chose the two checkboxes (test1 and test2) and enter his/her information the code will store the values to text c.

I am new in PHP, could please helping me to solve this problem, which I have spent three days to solve it without any result.

Thank you in advance

Posted: Sat Nov 20, 2004 2:20 pm
by rehfeld

Code: Select all

<?php

$name = $_POST['name'];
$email = $_POST['email'];
$city = $_POST['city'];

if (isSet($_POST['checkbox1']) && isSet($_POST['checkbox2'])) {

    $text = 'c';

} elseif (isSet($_POST['checkbox1'])) {

    $text = 'a';

} elseif (isSet($_POST['checkbox2'])) {

    $text = 'b';

}


if (isSet($text)) {
    // do something, log it, email it etc.....
}





?>

Posted: Sat Nov 20, 2004 3:37 pm
by Syrman
Thanks rehfeld, I will try this

Greetings