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
https://forums.phpfreaks.com/topic/297062-select-period-coding-help/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.