help please with this form broblem

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
Syrman
Forum Newbie
Posts: 2
Joined: Sat Nov 20, 2004 1:58 pm

help please with this form broblem

Post 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
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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.....
}





?>
Syrman
Forum Newbie
Posts: 2
Joined: Sat Nov 20, 2004 1:58 pm

Post by Syrman »

Thanks rehfeld, I will try this

Greetings
Post Reply