Jump to content

Select Period coding help


b0lero

Recommended Posts

Hey gay i did something but i don't know how to finish it :P There is the code

<?php
	if(isset($_POST['formSubmit'])) 
	{
		$aPeriod = $_POST['formPeriod'];
		
		if(!isset($aPeriod)) 
		{
			echo("<p>You didn't select period!</p>\n");
		} 
		else 
		{
			$nPeriod = count($aPeriod);
			
			echo("<p>The curent period is: $nPeriod : ");
			for($i=0; $i < $nPeriod; $i++)
			{
				echo($aPeriod[$i] . " ");
			}
			echo("</p>");
		}
	}
?>

<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
	<label for='formPeriod[]'>Select the period:</label><br>
	<select name="formPeriod[]">
		<option value="Vegetative">Vegetative</option>
		<option value="Flowering">Flowering</option>
		
	</select><br>
	<input type="submit" name="formSubmit" value="Submit" >
</form>

all i want to do is to save this submit into txt file so i don't have to submit the period in every visit into the web site :) any ideas ?

Link to comment
Share on other sites

OK almost understand what file_put_contents work ,

$file = __DIR__."/test.txt";
file_put_contents($file, "Hello, World!");
echo file_get_contents($file); 

i  also find in diferent format

<?php

      // Open the text file
      $f = fopen("test.txt", "w");

      // Write text line
      fwrite($f, "PHP is fun!");

      // Close the text file
      fclose($f);

      // Open file for reading, and read the line
      $f = fopen("test.txt", "r");
      echo fgets($f);

      fclose($f);

      ?>

witch is same function , but still the problem its same i can't connect it to my code witch alredy have or i need to do something totali differend

Edited by b0lero
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.