Jump to content

Archived

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

onekoolman

PHP Post/Echo Help

Recommended Posts

Heres the code:

[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'>";
?>[/code]

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)

[code]<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">[/code]

The form

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

Share this post


Link to post
Share on other sites
[code]
<?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'>";
    }
?>
[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[code]
<?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>
[/code]

Share this post


Link to post
Share on other sites

×

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.