Jump to content

PHP and #


Nitestarz78

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/#findComment-901929
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/#findComment-901988
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902030
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902045
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902053
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/171012-php-and/#findComment-902780
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.