Hey guys... Needed some help in PHP ..

Basically.. say.. I have 2 or more input fields and one text area.

Now, I want some sort of a php script that would use POST to extract submitted data from the inputfield1, inputfield2, and text-area.

The textarea is going to have numbers in each line .. say like..

123
133
124 .. etc

... Next.. is it possible to extract the information submitted above (field1, field2, and textarea) and form them in some sort of output box as such

field1 textarea field2

So.. say .. output would be something like:

field1 = username
textarea = serial number
field2 = command

result would be
sam 123 accept
dave 133 accept
nick 124 deny

etc etc

Is it possible?

:)

Lifetalk,
textarea has nothing to do with PHP, that's html. But, to answer your question, yes, it's possible to pretty much do anything.

I assume that if you are asking about php, you must have a clue as to how html forms work.
Well, in your html form action, all you must do is give the action the filename.ext of your processing php page, such as action='process.php' (and obviously the method='post' as this is your request).

Give each of your input fields "name attributes"

in our process.php page we will then need to refer to those names, so, let's say you have an input field name='serial_number' (no spaces please)... on your process.php page, you will need to say

<?PHP
$serialNumber = $_POST['serial_number'];
?>

test this out by adding below it
an echo

<?PHP
$serialNumber = $_POST['serial_number'];
echo $serialNumber;
?>

now, I wonder what kind of output box you are looking for. PHP (to my knowledge) does not have like a popup "alert" box like javascript does (unless I am mistaking on that one).

so, if you want submit to give you some sort of jump up on the screen and tell you the information, you are going to have to do a crazy mix of javascript with your php, which can get a tad bit messy, but I won't go into that unless you come back and say that is what you were looking for.

I know that it's hard to describe what you are looking to do (I have the same problem at times), but if you can attempt to be a little bit more clear I am sure someone (maybe even I) can help you.
Sage

Sage,

Thanks a lot for your help.. I'll try the PHP POST stuff today and post my results here.

If necessary, I'll draw everything out in Photoshop and post screenshots here .. just to be more clear :)

Thanks again.

Basically.. My main question was..

How would I go about separating each line in a 'textarea' and then having one variable that would append each line to the other two constants (field1 and field2 are constant, while 'textarea' has more than 1 line).

So, each line from textarea needs to be separately 'echoed' with the constants (field1 and field2).

:)

Not sure if you understand it now, but don't worry, I'll be posting screenshots once I give this a shot

Anyway, I've got round to doing a bit of what I want to achieve.
Take a look here
http://www.clipgamers.com/test

The directory listing has 2 files as of now..
-start.php
-process.php

Here's the code for process.php

<?PHP
$primary = $_POST['primary'];
$secondary = $_POST['secondary'];
$cidr = $_POST['cidr'];
$cidr = str_replace("\n","\n",$cidr);
?>

<HTML>
<BODY>
Meh... <br />

<?PHP
$gen=$gen.$primary;
$gen=$gen.$cidr;
$gen=$gen.$secondary;
?>

<br /><br />
<b>

<?PHP
echo "$gen";
?>

</b>

<br />
And that's the end..
</body>
</html>

Basically, what I wanted was..
To keep the first two variables asked for (in start.php named primary and secondary) constant.

Then, take the input from the textarea named 'CIDR' and break each line.

Append the 'primary' and 'secondary' (which is constant) to each line of 'CIDR' and then echo the output. One in each line.

Not sure if you still get what I want.. but hopefully things should be much clearer.

I've got round to doing most of it... Keeping the first two constant (lol) .. but for some reason, I am unable to add a line break in the text area and it is echoed as one.. instead of multiple lines..

Any ideas now?

Hello, any body can help me, i've try to show field textarea, but can't.. help me please.. herewith code:

<textarea type="text" name="alamat" rows="5" cols="40" value="<?php $_POST['$alamat']; ?>" /></textarea>

Hello, any body can help me, i've try to show field textarea, but can't.. help me please.. herewith code:

<textarea type="text" name="alamat" rows="5" cols="40" value="<?php $_POST['$alamat']; ?>" /></textarea>

try

<textarea .......><?php echo $_POST['alamat'];?></textarea>

still cannot shows :(

still cannot shows :(

is your question is
text area is shown but no value in it???

yes, i mean fields in text area cannot be shown, after inserted one data, when i try to edit the data, only fields in text area cannot be shown..

yes, i mean fields in text area cannot be shown, after inserted one data, when i try to edit the data, only fields in text area cannot be shown..

then most probably your selection from db is not right

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.