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!
now using php I am going to set a variable named $selected and in that variable I want to store the value that the user selects. Does anyone knows how I can get the selected data?
What PHP script will receive the data from this form? You haven't provided an action= parameter, so your code will default to calling the same script again. If this is what you intend, then your script will have to have some code to determine whether it should just display the form (the first time it is called) or whether it should look for user form data and take some action based on that. You should probably read some tutorials on using POST variables, such as http://www.html-form-guide.com/php-form ... -post.html. Basically, the script that handles the form data will find the value selected in the $_POST array, using the index "file" (the name you have assigned to the select element of your form).
<?php
$fn = "test.txt";
if (isset($_POST['content']))
{
$content = stripslashes($_POST['content']);
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
}
?>