i need a little help with my php code
here's my whole code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST['filename']))
{
$schanName[] = 'File Name is Required';
}
if($_POST['thisfolder'] == 'default')
{
$schanName[] = 'Please select a Folder';
}
$filename=$_POST['filename'];
$words = array("1", "2", "3", "4", "5");
$arrlength = count($words);
$found = false;
for($x = 0; $x < $arrlength; $x++)
{
if($filename == $words[$x])
{
$found = true;
}
}
if($found)
{
$schanName[] = 'Not a valid File Name';
}
// the name of the file to create
$filename=$_POST['filename'];
// the name of the file to be in page created
$strin=$_POST['strin'];
// the name of the file to be in page created
$strin2=$_POST['strin2'];
// the name of the folder to put $filename in
$thisFolder = $_POST['thisfolder'];
// make sure #thisFolder of actually a folder
if (!is_dir(__DIR__.'/'.$thisFolder))
{
// if not, we need to make a new folder
mkdir(__DIR__.'/'.$thisFolder);
}
// . . . /[folder name]/page[file name].php
$myFile = __DIR__.'/'.$thisFolder. "/page" .$filename.".php";
// This is another way of writing an if statment
$div = ($strin !== '') ? '<div id="area_code">'.$strin.'</div>' : '<div id="area_code">'.$strin2.'</div>';
$fh = fopen($myFile, 'w');
$stringData = "";
fwrite($fh, $stringData);
fclose($fh);
}
?>
<?php
// display your errors here
if(!empty($schanName))
{
foreach ($schanName as $sn)
{
echo '<div id="error"><ul><li>'.$sn.'</li></ul></div>';
}
}
?>
<form class="s_submit" method="post">
<label class="def_lab">File:</label>
<input class="t_box" type='text' name='filename' placeholder='File Name'>
<label class="t_lab def_lab">Select Folder:</label>
<select id="soflow" name="thisfolder">
<option selected="selected" value="default">Default</option>
<option value="../embed/tv/xbox/">Xbox</option>
<option value="Folder2">Folder2</option>
<option value="Folder3">Folder3</option>
</select><br><br>
<label class="def_lab">Text Area 1:</label><br>
<textarea class="tarea_box" type='text' name='strin'></textarea><br><br>
<label class="def_lab">Text Area 2:</label><br>
<textarea class="tarea_box" type='text' name='strin2'></textarea><br>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</body>
</html>
what i am trying to do here is , when i clicked o submit button it must show me YES and NO options. if i clicked on YES then it must excute the code and if i clicked NO then do nothing. hope you get it