0

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

4
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by puvi
0

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

<select name="actor" id="actor">
<option>John</option>
<option>Tom Hanks</option>
<option>Harry</option>
</select>
<input type="submit" name="btnSubmit" value="Submit" />
</form>
<?php
$a=$_POST['actor'];
echo $a;
?>

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

0

thanks pritaeas and anilashanbhag

guys, have a look at my code.

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

0

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

0

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>
</select>
<input type="submit" name="btnSubmit" value="Submit" />
</form>
<?php

echo $_POST;
?>

0

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" >
<option>..</option>
	<?php 

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

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.