Jump to content
php.lv forumi

teksta saglabashana ar formas palidzibu db


marlboro

Recommended Posts

Galējais kods varētu būt sekojošs:

<?php
$select_opts = array(1,2);

if ($_REQUEST['saturs'])
$saturs = (int)$_GET['saturs'];
else
$saturs = 0;

if (!in_array($saturs, $select_opts))
$saturs = 0;
?>
<form name="form_select_content" method="get" id="form_select_content">
Izvelies lapu :
<select name="saturs" onchange="document.forms['form_select_content'].submit();">
<option value="0"<?php if ($saturs==0) echo ' selected';?>></option>
<?php
foreach ($select_opts as $val) {
echo '<option value="'.$val.'"' . ($saturs==$val ? ' selected' : '') . '>saturs '.$val.'</option>';
}
?>
</select>
</form>

<form name="form_main" method="post" action="updatePage.php">

<br><textarea rows="10" cols="60" name="contents">

<?php

if($saturs == 1){
echo "$contents";

}else{
echo "nau!!";
}
?>
</textarea>
<input type="submit" name="Submit" value="Saglabat">
</form>

Link to comment
Share on other sites

×
×
  • Create New...