Hi ppl,

I am trying to save the details of a form on clicking submit into a database. the details entered in text box get saved, but the options chosen from drop down are not getting saved. I noticed that, if the option has space (Eg: Tom Hanks) it doesnt get saved. If its a single word like John there is no issue. when i try to echo this option(Tom Hanks) only Tom gets printed.

I am not able to figure the what is the issue? is it necessary to have a single word as option or is it issue with $_POST and i ve put it thru some function.

any help/suggestion most appreciated.

Thank you ppl of the forum..

6 Years
Discussion Span
Last Post by puvi

<form action="this.php" method="post">

<select name="actor" id="actor">
<option>Tom Hanks</option>
<input type="submit" name="btnSubmit" value="Submit" />
echo $a;

the code is like this, now if u select John it prints, but if u select Tom Hanks it wont.


thanks pritaeas and anilashanbhag

guys, have a look at my code.

anilashanbhag, i tried what u mentioned that dint work, it pprints only tom :(


no i thought u have put the value already and still it didnt print

if it is solved then fine

else try value = "tom\ hanks" once


Simply do it the following way

<form method = "post">
<select name="actor">
<option value="John">John</option>
<option value="Tom">Tom Hanks</option>
<option value="Harry">Harry</option>
<input type="submit" name="btnSubmit" value="Submit" />

echo $_POST;


thanks all that worked fine, but when i tried to get the options of the dropdown from database, then tried to print, it doesnt happen again, the html code of dropdown is as follows

<select name="component" id="component" >

	while($rowComp = mysql_fetch_array($resComp))
	echo "<option id=".$rowComp['id']." value=".$rowComp['name'].">".$rowComp['name']."</option>";

is something wrong with this code? only 1st word of the option is printed.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.