Nitestarz78 Posted August 19, 2009 Share Posted August 19, 2009 I have a form that processes and e-mails the information correctly. However it does not print out correctly on the thank you page. It seems to be chopping off and removing the # from the name. Form code: <?php $Interests = is_array($_POST['Interests']) ? $_POST['Interests'] : array(); ?> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#" <?php if(in_array(.NET Using C#',$Interests)) echo " SELECTED"; ?>>.NETUsing C#</option> </select> On the thank you page it would print out: .NET Using C and it would cut off any other selected fields as well. Thank You page code: <strong>Interest(s):</strong<br>" . implode("<br>",$Interests) . "<br/> Any ideas? What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/ Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 missing a quote! <?php $Interests = is_array($_POST['Interests']) ? $_POST['Interests'] : array(); ?> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#" <?php if(in_array('.NET Using C#',$Interests)) echo " SELECTED"; ?>>.NETUsing C#</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-901929 Share on other sites More sharing options...
Nitestarz78 Posted August 19, 2009 Author Share Posted August 19, 2009 Oops! Fixed that it still doesnt work. Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-901968 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 I can't re-create the problem the below code works fine <?php //$_POST['Interests'] = array('.NET Using C#'); $Interests = is_array($_POST['Interests']) ? $_POST['Interests'] : array(); ?> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#" <?php if(in_array('.NET Using C#',$Interests)) echo " SELECTED"; ?>>.NETUsing C#</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-901988 Share on other sites More sharing options...
Nitestarz78 Posted August 19, 2009 Author Share Posted August 19, 2009 It does print out on the thank you page, but it somehow removes the # Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902021 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 Link = http://madtechiesupport.com/265770.php tested in IE8, FF3.5, Safari 4.0.3 (all work fine) code <?php $_POST['Interests'] = array('.NET Using C#'); $Interests = is_array($_POST['Interests']) ? $_POST['Interests'] : array(); ?> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#" <?php if(in_array('.NET Using C#',$Interests)) echo " SELECTED"; ?>>.NETUsing C#</option> </select> Screen shot [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902030 Share on other sites More sharing options...
Nitestarz78 Posted August 19, 2009 Author Share Posted August 19, 2009 Yes, that portion of the form works correctly.....After it is processed it is sent to a thank you page where the information is printed out. This is where it looses the # For example, it would print: .NET Using C The thank you page retrieves the information from the form via GET Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902045 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 Well that's a completely different question, You can't just send # via the URL as its a URL syntax character, your need to encode it use urlencode() and urldecode() to decode it # = %23 echo urlencode("#"); Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902048 Share on other sites More sharing options...
rhodesa Posted August 19, 2009 Share Posted August 19, 2009 How are you printing it on the thankyou page? This works fine for me: <?php print_r($_POST); ?> <form action="" method="POST"> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#">.NETUsing C#</option> </select> <input type="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902053 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 He said his using GET but who know! Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902068 Share on other sites More sharing options...
rhodesa Posted August 20, 2009 Share Posted August 20, 2009 this works fine for me too <?php print_r($_GET); ?> <form action="" method="GET"> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#">.NETUsing C#</option> </select> <input type="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902524 Share on other sites More sharing options...
MadTechie Posted August 20, 2009 Share Posted August 20, 2009 Yes it will work but as his having problems I'll have to assume his using a URL this thread is pretty unclear, Without any valid information most of the work is guess work, but for anyone else who reading this here's a good/bad example <?php print_r($_GET); ?> <form action="" method="GET"> <select name="Interests[]" multiple="multiple" size="10"> <option value=".NET Using C#">.NETUsing C#</option> </select> <input type="text" name="fine" value="can you see me"/> <input type="submit" value="This works fine"/> </form> <a href="?Interests=.NET Using C#&fine=can you see me">Bad Link</a><br> <!--Long good example: note that %20 could be replaced with + --> <a href="?Interests=.NET%20Using%20C%23&fine=can%20you%20see%20me">GoodLink</a><br> <!-- let PHP encode for you --> <a href="?Interests=<?php echo urlencode('.NET Using C#');?>&fine=<?php echo urlencode('can you see me');?>">GoodLink</a> Quote Link to comment https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902780 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.