t4tipu Posted October 10, 2008 Share Posted October 10, 2008 Save the code below in "test.php" and execute... When i select the third option i-e "This is the sentence", only "This" is posted and the data after this is not echoed/posted... Please help... <?php if("$_POST[submit]"=="Update") { $hello=$_POST['list']; echo "You selected : ".$hello; } ?> <form action="test.php" method="POST"> <select name="list"> <option value="">Select1</option> <option value="Select2">Select2</option> <?php $var="This is the sentence"; echo "<option value=".$var.">".$var."</option>"; ?> </select> <input class="button" type='submit' name="submit" value="Update"> </form> Link to comment https://forums.phpfreaks.com/topic/127827-help-data-loss-after-spce-simple-problem/ Share on other sites More sharing options...
trq Posted October 10, 2008 Share Posted October 10, 2008 Your html is malformed. "<option value='".$var."'>".$var."</option>"; Don't Freak Out!!! Link to comment https://forums.phpfreaks.com/topic/127827-help-data-loss-after-spce-simple-problem/#findComment-661757 Share on other sites More sharing options...
t4tipu Posted October 10, 2008 Author Share Posted October 10, 2008 "Your html is malformed." What is meant by this??? And whats the solution??? Link to comment https://forums.phpfreaks.com/topic/127827-help-data-loss-after-spce-simple-problem/#findComment-661768 Share on other sites More sharing options...
t4tipu Posted October 10, 2008 Author Share Posted October 10, 2008 <?php $var="This is the sentence"; echo "<option value=".$var.">".$var."</option>"; echo "<input type='hidden' name='yellow' value='$var'>"; ?> Its finally working/// Link to comment https://forums.phpfreaks.com/topic/127827-help-data-loss-after-spce-simple-problem/#findComment-661774 Share on other sites More sharing options...
trq Posted October 10, 2008 Share Posted October 10, 2008 I posted the solution. the contents of the value attribute need to be within quotes. Theres a few other issues with the code though (I didn't notice earlier). Here, is what it ought look like: <?php if (isset($_POST['submit'])) { $hello=$_POST['list']; echo "You selected : ".$hello; } ?> <form action="test.php" method="POST"> <select name="list"> <option value="">Select1</option> <option value="Select2">Select2</option> <?php $var="This is the sentence"; echo " <option value='$var'>$var</option>"; ?> </select> <input class="button" type='submit' name="submit" value="Update"> </form> Link to comment https://forums.phpfreaks.com/topic/127827-help-data-loss-after-spce-simple-problem/#findComment-661775 Share on other sites More sharing options...
t4tipu Posted October 10, 2008 Author Share Posted October 10, 2008 Thankyour thrope... You finally solved the prob Link to comment https://forums.phpfreaks.com/topic/127827-help-data-loss-after-spce-simple-problem/#findComment-661792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.