I want to find a way to store the selected option from dropdown list before the submit. so i can handle it to the form input value.
Im new to php.
Thanks in advance.
I tried to use this $katigoriaselected=$_POST['options'];
and store the selected item to <input type='hidden' name='katigoriaslc' value='$katigoriaselected'>
if(isset($_SESSION['userID'])){
$onoma = $_SESSION['username'];
$mnpstusrid = $_SESSION['userID'];
echo "<form method='POST' action='".setPosts($conn)."'>
<input type='hidden' name='mainpstuserid' value='$mnpstusrid'>
<input type='text' name='pstTittle' placeholder='Τιτλος Δημοσιευσης'><br><br>
<p>ΚΑΤΗΓΟΡΙΕΣ<br>
<select name='options'>
<option value='Astia'>ΑΣΤΕΙΑ</option>
<option value='Tainies'>ΤΑΙΝΕΙΕΣ</option>
<option value='anim'>ANIME</option>
</select><br>
$katigoriaselected=$_POST['options'];
<input type='hidden' name='mainpostusername' value='$onoma'>
<input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
<textarea name='mainpost'></textarea><br>
<button name='usrmainpostsubmit' type='submit' class='mainpstbutton1'>Post</button>
</form>";
}
?>```
the error message :
```Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)```
It seems that i was doing my job harder wo a reason it's pointless to store the variable to sth when you dont need to. I could just send it straight to my function controller. I didnt know u can pass <select name='options'>
(from index.php) to $katigoria = $_POST['options'];
.(to myfunction.php).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.