Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php: new line code question

    hi there. I have a php script where you input some things from radio buttons and text boxes, and when you submit it, it puts it in a text box already formatted, and all u have to do is copy/paste.

    i have created new line entries in the php script and they work, like this:

    <snip>
    <?php echo$_POST['prblm']; echo"\n";?>
    </snip>

    but, that will put in a new line even if that item (in this case, 'prblm') is not used.

    is there a way to..."activate' it when that item is used, but not have it show up if the item is not used?

    did this make any sense?

    any help is greatly appreciated.

    thanks.

    dan
    dan

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Dunno what you mean really, but hope this helps

    PHP Code:
    <snip>
    <?php 
    $postage 
    $_POST['prblm'];

    if(
    $postage)
    {
        echo
    "\n";
    }
    ?>
    </snip>
    Prolly a completely easier way to do it, but I've been around town for the night and that's the only way that came to mind

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re:

    I tried this, but it is not posting my 'prblm' information. i will tinker with this for a bit tonight.

    thanks for the reply.

    dan
    dan

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <snip>
    <?php 
    $postage 
    $_POST['prblm'];

    if(
    $postage)
    {
        echo 
    $postage "\n";
    }
    ?>
    </snip>
    maybe?

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,095
    Thanks
    11
    Thanked 101 Times in 99 Posts
    may as well stop internal error messages ( if $_POST['prblm'] is ! set ) while you are at it...

    PHP Code:
    <?php
    if( isset( $_POST['prblm'] ) ) {
       echo 
    $_POST['prblm'] . "\n" ;
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #6
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re:

    I have tried the eamples above, but unofrtunately they are still creating new line entries when they are not being used. I will keep trying, tho.

    thanks for all the help.
    dan

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post oops

    oh boy...i totally forgot...ya'll are gonna hate me...

    the 'prblm' output is being written to a text box, where it can be copied.

    i cant believe i forgot to tell you that...i apologize....

    is it even possible/worth it now?
    dan

  • #8
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is the form method post?
    in a html or php file try...

    <form method="post" action="phpfile.php">
    <input name="prblm" type="text">
    </form>

    then in the phpfile.php
    if isset($_GET['prblm']){
    $prblm=$_GET['prblm'];
    echo $prblm;
    }
    echo "\n";

  • #9
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    still nothing

    I am using POST as the method.

    here is what i have so far:

    <?php

    if( isset($_POST['prblm'])){

    $prblm=$_POST['prblm']. "\n";
    echo $prblm;
    }
    ?>

    it is still showing the blank ("new") line.

    Am i missing something here? I have tried different ways, like:

    $prblm=$_POST['prblm']. "\n";
    $prblm=$_POST['prblm'], "\n"; <--generates error
    $prblm=$_POST['prblm'. "\n"]; <-- still generates blank line
    $prblm=$_POST['prblm', "\n"]; <-- generates error

    i think i am getting close (thanks to everyone), but this is getting pretty frustrating. I realized taht if i put a space behind the php clsing tag, then that will create a new line; otherwise, the php post items will appear on the same line.

    grrr........

    thanks,
    dan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •