Jump to content


Photo

PHP Post/Echo Help


  • Please log in to reply
5 replies to this topic

#1 onekoolman

onekoolman
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 08 June 2006 - 04:01 PM

Heres the code:

<?php
if($_POST['$value'] == 'a' || 'b' || 'c' || 'd' || 'e' || 'f' || 'g' || 'h' || 'i' || 'j' || 'k' || 'l' || 'm' || 'n' || 'o' || 'p' || 'q' || 'r' || 's' || 't' || 'u' || 'v' || 'w' || 'x' || 'y' || 'z')
echo "<img src='http://www.domain.com/styles/1/images";
echo "/";
echo "$value";
echo ".gif'>";
?>

Is there a way, so that ANY time a letter is typed in a textarea it is posted as an image? If theres a space I want blank.gif to display.

Example:

"I Type This"

I want: (To be displayed)

<img src="http://www.domain.com/styles/1/images/i.gif">
<img src="http://www.domain.com/styles/1/images/blank.gif">
<img src="http://www.domain.com/styles/1/images/t.gif">
<img src="http://www.domain.com/styles/1/images/y.gif">
<img src="http://www.domain.com/styles/1/images/p.gif">
<img src="http://www.domain.com/styles/1/images/e.gif">
<img src="http://www.domain.com/styles/1/images/blank.gif">
<img src="http://www.domain.com/styles/1/images/t.gif">
<img src="http://www.domain.com/styles/1/images/h.gif">
<img src="http://www.domain.com/styles/1/images/i.gif">
<img src="http://www.domain.com/styles/1/images/s.gif">

The form

<form action="post.php" method="POST">
<text area name="value" rows="50" cols="10">
</textarea>
</form>


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 June 2006 - 04:18 PM

<?php
  $blah = "I type this";
    $blah = strtolower($blah);
    $letters = preg_split('//', $blah, -1, PREG_SPLIT_NO_EMPTY);
    foreach ($letters as $val) {
       if ($val == " ") { $val = "blank"; }
          echo "<img src='http://www.domain.com/styles/1/images/".$val.".gif'>";
    }
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 08 June 2006 - 04:20 PM

I know its a bit more advanced but you can get PHP's GD2 to 'draw' the letter as an image for you.

I dont have the code in front of me, but thats how those Captcha (security code images) work.



#4 onekoolman

onekoolman
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 08 June 2006 - 04:29 PM

Wow, fast reply, and it works, thank you very much.

#5 onekoolman

onekoolman
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 08 June 2006 - 04:49 PM

I am having trouble getting $blah from the form, (Im a noobie)

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 June 2006 - 04:59 PM

<?php
  $blah = $_POST['example'];
    //$blah = "I type this";
    $blah = strtolower($blah);
    $letters = preg_split('//', $blah, -1, PREG_SPLIT_NO_EMPTY);
    foreach ($letters as $val) {
       if ($val == " ") { $val = "blank"; }
          echo "<img src='http://www.domain.com/styles/1/images/".$val.".gif'>";
    }
?>

<form action="<?= $PHP_SELF ?>" method="POST">
 example: <input type='text' name='example'>
<input type='submit'>
</form>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users