...

View Full Version : php: new line code question



biggyfries
10-18-2003, 11:56 PM
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

Nightfire
10-19-2003, 01:50 AM
Dunno what you mean really, but hope this helps



<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 :)

biggyfries
10-19-2003, 02:24 AM
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

Nightfire
10-19-2003, 04:36 AM
<snip>
<?php
$postage = $_POST['prblm'];

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

maybe?

firepages
10-19-2003, 12:47 PM
may as well stop internal error messages ( if $_POST['prblm'] is ! set ) while you are at it...



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

biggyfries
10-21-2003, 02:01 AM
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.

biggyfries
10-21-2003, 02:17 AM
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?

nicklim
10-21-2003, 04:25 AM
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";

biggyfries
10-25-2003, 03:39 AM
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,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum