Jump to content

Recommended Posts

I have read several threads relating to this but everything had to do with not passing data to DB. I have a post generator for a forum that outputs code with proper (vb) code tags, img tags and text tags. If a field is left blank by the user it will still have the tags in the generated post.

 

Is there a way skip the "echo" output if there is no text entered? I guess another solution is to have check boxes where the user could check only the info they wished to enter.

 

Either way if I could get a little push in the right direction will give it a shot.

 

Thanks

 

Here is the code

<tr>
    <td><b>Download Title:</b></td>
    <td><input type="text" name="downloadtitle" size="57"></td>
</tr>
<tr>
    <td><b>Images</b> <small>(One Per Line)</small>:</td>
    <td><textarea name="images" rows="4" cols="43"></textarea></td>
</tr>
<tr>
    <td><b>Information:</b></td>
    <td><textarea name="information" rows="5" cols="43"></textarea></td>
</tr>
<tr>
    <td><b>Tracklist:</b></td>
    <td><textarea name="tracklist" rows="5" cols="43"></textarea></td>
</tr>
<tr>
    <td><b>Bit Rate:</b></td>
    <td><textarea name="bitrate" rows="1" cols="43"></textarea></td>
</tr>
<tr>
    <td><b>File Size:</b></td>
    <td><textarea name="filesize" rows="1" cols="43"></textarea></td>
</tr>
<tr>
    <td><b>Download Links</b> <small>(One Per Line)</small>:</td>
    <td><textarea name="downloadlinks" rows="4" cols="43"></textarea></td>
</tr>
<tr>
    <td><b>File Password:</b></td>
    <td><input type="text" name="filepassword" size="57"></td>
</tr>
</table>
<input type="submit" value="Generate Evo Post" name="generatepost"><input type="reset" value="Clear Input Boxes">
</form>
<br /><br />
<?php
if (isset($_REQUEST['generatepost'])){
    $downloadtitle = $_POST['downloadtitle'];
    $images = @$_POST['images'];
    $images = explode("\n", $images);
    $images = array_unique($images);
    $information = $_POST['information'];
    $tracklist = $_POST['tracklist'];
    $bitrate = $_POST['bitrate'];
    $filesize = $_POST['filesize'];
    $downloadlinks = $_POST['downloadlinks'];
    $filepassword = $_POST['filepassword'];
    echo "<b>Generated Post:</b><br />";
    echo "<textarea name=\"generatedpost\" rows=\"15\" cols=\"60\">";
    echo "[b][u]".$downloadtitle."[/u][/b]";
    echo "\n\n";
    foreach($images as $allimages){
        $allimages = trim($allimages);
        echo "[img=http://".$allimages."]\n";
    }
    echo "\n[b]Information:[/b]\n[quote]".$information."[/quote]";
    echo "\n[b]Tracklist:[/b]\n[quote]".$tracklist."[/quote]";
    echo "\n[b]Bite Rate:[/b]\n[quote]".$bitrate."[/quote]";
    echo "\n[b]File Size:[/b]\n[quote]".$filesize."[/quote]";
    echo "\n\n[b]Download:[/b]\n[code]".$downloadlinks."

";

    echo "\n\nFile Password:\n

".$filepassword."

";

    echo "</textarea>";

}

?>

[/code]

 

 

and you can find the generator here.

http://bobbyallen.byethost2.com/postgen.php

Link to comment
https://forums.phpfreaks.com/topic/164283-solved-empty-text-box-inputs/
Share on other sites

just put in IF statements:

<?php
if (isset($_REQUEST['generatepost'])){
    $downloadtitle = $_POST['downloadtitle'];
    $images = @$_POST['images'];
    $images = explode("\n", $images);
    $images = array_unique($images);
    $information = $_POST['information'];
    $tracklist = $_POST['tracklist'];
    $bitrate = $_POST['bitrate'];
    $filesize = $_POST['filesize'];
    $downloadlinks = $_POST['downloadlinks'];
    $filepassword = $_POST['filepassword'];
    echo "<b>Generated Post:</b><br />";
    echo "<textarea name=\"generatedpost\" rows=\"15\" cols=\"60\">";
    if(!empty($downloadtitle))
      echo "[b][u]".$downloadtitle."[/u][/b]";
etc....
?>

just put in IF statements:

 

 

Well that turned out pretty easy. I had read through the book but looked more at if/then statements. After you post I went back and if would have read a little more could have got it.

 

Thanks for the assistance.

The key to the if statement is thus the condition to be evaluated, which is always enclosed in parentheses. If the condition evaluates to true, the code within the curly braces is executed; if it evaluates to false, the code within the curly braces is skipped. This true/false test is performed using PHP’s comparison operators, which you learned about in the

preceding chapter; Table 3-1 quickly recaps them.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.