 |
|
 |
|
Next: Generating PDF file and sending as email attachme..
|
| Author |
Message |
External

Since: Sep 15, 2006 Posts: 6
|
(Msg. 1) Posted: Tue Sep 26, 2006 12:43 pm
Post subject: Form Data -> Variables or an Array? Archived from groups: comp>lang>php (more info?)
|
|
|
Hi I need help!
Forgive me I am a PHP newbie. I have a small script that enables me to send
a form from an HTML page. I want to use the HTML formatted form because the
design of my website is complex, and I don't want to have to mess around
with formatting a page using HTML within php. So basically the "action" of
the HTML page sends the form to "ProcReg.php". This is the code:
<?php
/* Script name: ProcReg.php
* Description: Script displays all the information passed
* from a form.
*/
echo "<html>
<head><title>Registration Information</title></head>
<body>";
foreach ($_REQUEST as $field => $value)
{
echo "$field = $value<br>";
}
?>
</body>
</html>
-------
This is what I get as a "return", at the moment to a blank web page:
First_Name = First Name
Last_Name = Last Name
Address1 = Address Line 1
Address2 = Address Line 2
Address3 = Address Line 3
TownCity = Town/City
CountyStateProvince = County, State or Province
PostZipCode = Post Code/Zip Code
Country = 000
e-mail1i = Your E-Mail Address
email1v = Confirm Your E-mail Address
email2i = Your Alternative E-Mail Address
email2v = Confirm Your E-Mail Address
intcode = 000
areacode = 000
telnum = 000000
username = Username
password = xxxxxxx
mailinglist = Yes
clubfbd = Yes
B1 = Submit
---
I just want to know how I can modify the php code in the ProcReg script so
that the instead of writing the "return" to a web page, it writes it to
variables or an array, so that I can call the data later in the same script
to be checked?
I am sure I know how to do the checking, but not how to get the data into
variables or an array.
Regards,
C.B. >> Stay informed about: Form Data -> Variables or an Array? |
|
| Back to top |
|
 |  |
External

Since: Sep 26, 2006 Posts: 2
|
(Msg. 2) Posted: Tue Sep 26, 2006 2:04 pm
Post subject: Re: Form Data -> Variables or an Array? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Cerebral Believer" wrote in message
> Hi I need help!
>
> Forgive me I am a PHP newbie. I have a small script that enables me to
> send
> a form from an HTML page. I want to use the HTML formatted form because
> the
> design of my website is complex, and I don't want to have to mess around
> with formatting a page using HTML within php. So basically the "action"
> of
> the HTML page sends the form to "ProcReg.php". This is the code:
>
> <?php
> /* Script name: ProcReg.php
> * Description: Script displays all the information passed
> * from a form.
> */
> echo "<html>
> <head><title>Registration Information</title></head>
> <body>";
> foreach ($_REQUEST as $field => $value)
> {
> echo "$field = $value<br>";
> }
> ?>
> </body>
> </html>
>
> -------
>
> This is what I get as a "return", at the moment to a blank web page:
>
> First_Name = First Name
> Last_Name = Last Name
> Address1 = Address Line 1
> Address2 = Address Line 2
> Address3 = Address Line 3
> TownCity = Town/City
> CountyStateProvince = County, State or Province
> PostZipCode = Post Code/Zip Code
> Country = 000
> e-mail1i = Your E-Mail Address
> email1v = Confirm Your E-mail Address
> email2i = Your Alternative E-Mail Address
> email2v = Confirm Your E-Mail Address
> intcode = 000
> areacode = 000
> telnum = 000000
> username = Username
> password = xxxxxxx
> mailinglist = Yes
> clubfbd = Yes
> B1 = Submit
>
> ---
>
> I just want to know how I can modify the php code in the ProcReg script so
> that the instead of writing the "return" to a web page, it writes it to
> variables or an array, so that I can call the data later in the same
> script
> to be checked?
>
> I am sure I know how to do the checking, but not how to get the data into
> variables or an array.
>
> Regards,
> C.B.
Hi CB,
$_REQUEST IS an array , you just have to call it whenever you need to.
It is populated with NAMED rather than numbered elements which is possibly
where you are confused
the B1 element is the name of your 'button' and 'Submit' is the text shown
on its face.
the other values are the names of the fields and the values they held when
the submit took place.
If you want to put the values into another array, just use
$myArray = $_REQUEST;
but why bother ?
try
var_dump($_REQUEST);
to see all the details
Cheers
Ron >> Stay informed about: Form Data -> Variables or an Array? |
|
| Back to top |
|
 |  |
External

Since: Sep 15, 2006 Posts: 6
|
(Msg. 3) Posted: Tue Sep 26, 2006 3:49 pm
Post subject: Re: Form Data -> Variables or an Array? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Ron Barnett" wrote in message
> "Cerebral Believer" wrote in message
>
>> Hi I need help!
>>
>> Forgive me I am a PHP newbie. I have a small script that enables me to
>> send
>> a form from an HTML page. I want to use the HTML formatted form because
>> the
>> design of my website is complex, and I don't want to have to mess around
>> with formatting a page using HTML within php. So basically the "action"
>> of
>> the HTML page sends the form to "ProcReg.php". This is the code:
>>
>> <?php
>> /* Script name: ProcReg.php
>> * Description: Script displays all the information passed
>> * from a form.
>> */
>> echo "<html>
>> <head><title>Registration Information</title></head>
>> <body>";
>> foreach ($_REQUEST as $field => $value)
>> {
>> echo "$field = $value<br>";
>> }
>> ?>
>> </body>
>> </html>
>>
>> -------
>>
>> This is what I get as a "return", at the moment to a blank web page:
>>
>> First_Name = First Name
>> Last_Name = Last Name
>> Address1 = Address Line 1
>> Address2 = Address Line 2
>> Address3 = Address Line 3
>> TownCity = Town/City
>> CountyStateProvince = County, State or Province
>> PostZipCode = Post Code/Zip Code
>> Country = 000
>> e-mail1i = Your E-Mail Address
>> email1v = Confirm Your E-mail Address
>> email2i = Your Alternative E-Mail Address
>> email2v = Confirm Your E-Mail Address
>> intcode = 000
>> areacode = 000
>> telnum = 000000
>> username = Username
>> password = xxxxxxx
>> mailinglist = Yes
>> clubfbd = Yes
>> B1 = Submit
>>
>> ---
>>
>> I just want to know how I can modify the php code in the ProcReg script
>> so
>> that the instead of writing the "return" to a web page, it writes it to
>> variables or an array, so that I can call the data later in the same
>> script
>> to be checked?
>>
>> I am sure I know how to do the checking, but not how to get the data into
>> variables or an array.
>>
>> Regards,
>> C.B.
>
> Hi CB,
>
> $_REQUEST IS an array , you just have to call it whenever you need to.
>
> It is populated with NAMED rather than numbered elements which is possibly
> where you are confused
>
> the B1 element is the name of your 'button' and 'Submit' is the text shown
> on its face.
> the other values are the names of the fields and the values they held when
> the submit took place.
>
> If you want to put the values into another array, just use
>
> $myArray = $_REQUEST;
>
> but why bother ?
>
> try
> var_dump($_REQUEST);
> to see all the details
Thanks Ron,
Let me just get this straight, a from created from just HTML can have the
fields and values from it extracted and processed by a php script? There is
no other php on my original page, just the form action sending the form to
ProcReg.php. I just want to use ProcReg.php to collect data from an HTML
form, check for blank fiels and valid data, then send it to another HTML
page. I think I have the code for blank field checking and valid data
checking, but, I don't quite know how to send the form back to another fresh
HTML page where a user can make edits if needed.
Regards,
C.B. >> Stay informed about: Form Data -> Variables or an Array? |
|
| Back to top |
|
 |  |
External

Since: Sep 26, 2006 Posts: 2
|
(Msg. 4) Posted: Tue Sep 26, 2006 5:28 pm
Post subject: Re: Form Data -> Variables or an Array? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Cerebral Believer" wrote in message
> "Ron Barnett" wrote in message
>
>> "Cerebral Believer" wrote in message
>>
>>> Hi I need help!
>>>
>>> Forgive me I am a PHP newbie. I have a small script that enables me to
>>> send
>>> a form from an HTML page. I want to use the HTML formatted form because
>>> the
>>> design of my website is complex, and I don't want to have to mess around
>>> with formatting a page using HTML within php. So basically the
>>> "action" of
>>> the HTML page sends the form to "ProcReg.php". This is the code:
>>>
>>> <?php
>>> /* Script name: ProcReg.php
>>> * Description: Script displays all the information passed
>>> * from a form.
>>> */
>>> echo "<html>
>>> <head><title>Registration Information</title></head>
>>> <body>";
>>> foreach ($_REQUEST as $field => $value)
>>> {
>>> echo "$field = $value<br>";
>>> }
>>> ?>
>>> </body>
>>> </html>
>>>
>>> -------
>>>
>>> This is what I get as a "return", at the moment to a blank web page:
>>>
>>> First_Name = First Name
>>> Last_Name = Last Name
>>> Address1 = Address Line 1
>>> Address2 = Address Line 2
>>> Address3 = Address Line 3
>>> TownCity = Town/City
>>> CountyStateProvince = County, State or Province
>>> PostZipCode = Post Code/Zip Code
>>> Country = 000
>>> e-mail1i = Your E-Mail Address
>>> email1v = Confirm Your E-mail Address
>>> email2i = Your Alternative E-Mail Address
>>> email2v = Confirm Your E-Mail Address
>>> intcode = 000
>>> areacode = 000
>>> telnum = 000000
>>> username = Username
>>> password = xxxxxxx
>>> mailinglist = Yes
>>> clubfbd = Yes
>>> B1 = Submit
>>>
>>> ---
>>>
>>> I just want to know how I can modify the php code in the ProcReg script
>>> so
>>> that the instead of writing the "return" to a web page, it writes it to
>>> variables or an array, so that I can call the data later in the same
>>> script
>>> to be checked?
>>>
>>> I am sure I know how to do the checking, but not how to get the data
>>> into
>>> variables or an array.
>>>
>>> Regards,
>>> C.B.
>>
>> Hi CB,
>>
>> $_REQUEST IS an array , you just have to call it whenever you need to.
>>
>> It is populated with NAMED rather than numbered elements which is
>> possibly where you are confused
>>
>> the B1 element is the name of your 'button' and 'Submit' is the text
>> shown on its face.
>> the other values are the names of the fields and the values they held
>> when the submit took place.
>>
>> If you want to put the values into another array, just use
>>
>> $myArray = $_REQUEST;
>>
>> but why bother ?
>>
>> try
>> var_dump($_REQUEST);
>> to see all the details
>
> Thanks Ron,
>
> Let me just get this straight, a from created from just HTML can have the
> fields and values from it extracted and processed by a php script? There
> is no other php on my original page, just the form action sending the form
> to ProcReg.php. I just want to use ProcReg.php to collect data from an
> HTML form, check for blank fiels and valid data, then send it to another
> HTML page. I think I have the code for blank field checking and valid
> data checking, but, I don't quite know how to send the form back to
> another fresh HTML page where a user can make edits if needed.
>
> Regards,
> C.B.
Ah the plot thickens . . . .
So what you want to do is retrieve the data from a form and populate another
form ?
If you want to pass a value into an html form element, you just need to set
its 'value' when you output the form.
From your original example, you have a field called Address1
if we want to send that out to a screen containing a form that the user can
edit we just need to send:
// inside the form construction
echo "<input type='text' name='Address1'
Value='".$_REQUEST('Address1')."'>";
note the string is in two parts with $_REQUEST('Address1') concatenated in
the middle using the dot string operator.
Where things can get a bit tricky is if you have a series of controls -
typically radio buttons or checkboxes with the same name but different
values, here the returned value is another array that has to be examined,
hence my suggestion to examine the incoming data with var_dump() while
debugging.
The above example assumes that you know the name of the field, or you could
simply use $key and $value pairs as in your original posting inside a loop.
HTH
Ron >> Stay informed about: Form Data -> Variables or an Array? |
|
| Back to top |
|
 |  |
External

Since: Sep 15, 2006 Posts: 6
|
(Msg. 5) Posted: Tue Sep 26, 2006 5:28 pm
Post subject: Re: Form Data -> Variables or an Array? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Ron Barnett" wrote in message
> "Cerebral Believer" wrote in message
>
>> "Ron Barnett" wrote in message
>>
>>> "Cerebral Believer" wrote in message
>>>
>>>> Hi I need help!
>>>>
>>>> Forgive me I am a PHP newbie. I have a small script that enables me to
>>>> send
>>>> a form from an HTML page. I want to use the HTML formatted form
>>>> because the
>>>> design of my website is complex, and I don't want to have to mess
>>>> around
>>>> with formatting a page using HTML within php. So basically the
>>>> "action" of
>>>> the HTML page sends the form to "ProcReg.php". This is the code:
>>>>
>>>> <?php
>>>> /* Script name: ProcReg.php
>>>> * Description: Script displays all the information passed
>>>> * from a form.
>>>> */
>>>> echo "<html>
>>>> <head><title>Registration Information</title></head>
>>>> <body>";
>>>> foreach ($_REQUEST as $field => $value)
>>>> {
>>>> echo "$field = $value<br>";
>>>> }
>>>> ?>
>>>> </body>
>>>> </html>
>>>>
>>>> -------
>>>>
>>>> This is what I get as a "return", at the moment to a blank web page:
>>>>
>>>> First_Name = First Name
>>>> Last_Name = Last Name
>>>> Address1 = Address Line 1
>>>> Address2 = Address Line 2
>>>> Address3 = Address Line 3
>>>> TownCity = Town/City
>>>> CountyStateProvince = County, State or Province
>>>> PostZipCode = Post Code/Zip Code
>>>> Country = 000
>>>> e-mail1i = Your E-Mail Address
>>>> email1v = Confirm Your E-mail Address
>>>> email2i = Your Alternative E-Mail Address
>>>> email2v = Confirm Your E-Mail Address
>>>> intcode = 000
>>>> areacode = 000
>>>> telnum = 000000
>>>> username = Username
>>>> password = xxxxxxx
>>>> mailinglist = Yes
>>>> clubfbd = Yes
>>>> B1 = Submit
>>>>
>>>> ---
>>>>
>>>> I just want to know how I can modify the php code in the ProcReg script
>>>> so
>>>> that the instead of writing the "return" to a web page, it writes it to
>>>> variables or an array, so that I can call the data later in the same
>>>> script
>>>> to be checked?
>>>>
>>>> I am sure I know how to do the checking, but not how to get the data
>>>> into
>>>> variables or an array.
>>>>
>>>> Regards,
>>>> C.B.
>>>
>>> Hi CB,
>>>
>>> $_REQUEST IS an array , you just have to call it whenever you need to.
>>>
>>> It is populated with NAMED rather than numbered elements which is
>>> possibly where you are confused
>>>
>>> the B1 element is the name of your 'button' and 'Submit' is the text
>>> shown on its face.
>>> the other values are the names of the fields and the values they held
>>> when the submit took place.
>>>
>>> If you want to put the values into another array, just use
>>>
>>> $myArray = $_REQUEST;
>>>
>>> but why bother ?
>>>
>>> try
>>> var_dump($_REQUEST);
>>> to see all the details
>>
>> Thanks Ron,
>>
>> Let me just get this straight, a from created from just HTML can have the
>> fields and values from it extracted and processed by a php script? There
>> is no other php on my original page, just the form action sending the
>> form to ProcReg.php. I just want to use ProcReg.php to collect data from
>> an HTML form, check for blank fiels and valid data, then send it to
>> another HTML page. I think I have the code for blank field checking and
>> valid data checking, but, I don't quite know how to send the form back to
>> another fresh HTML page where a user can make edits if needed.
>>
>> Regards,
>> C.B.
> Ah the plot thickens . . . .
lol!
> So what you want to do is retrieve the data from a form and populate
> another form ?
Yes, that's correct.
> If you want to pass a value into an html form element, you just need to
> set its 'value' when you output the form.
>
> From your original example, you have a field called Address1
> if we want to send that out to a screen containing a form that the user
> can edit we just need to send:
> // inside the form construction
> echo "<input type='text' name='Address1'
> Value='".$_REQUEST('Address1')."'>";
Will this code populate a new form simply with data related to a field, or
will it actually create the field too?
> note the string is in two parts with $_REQUEST('Address1') concatenated in
> the middle using the dot string operator.
>
> Where things can get a bit tricky is if you have a series of controls -
> typically radio buttons or checkboxes with the same name but different
> values, here the returned value is another array that has to be examined,
> hence my suggestion to examine the incoming data with var_dump() while
> debugging.
That is something I may have to look into as I have a couple of Yes/No radio
buttons.
> The above example assumes that you know the name of the field, or you
> could simply use $key and $value pairs as in your original posting inside
> a loop.
OK thanks for your help.
Regards,
C.B. >> Stay informed about: Form Data -> Variables or an Array? |
|
| Back to top |
|
 |  |
| Related Topics: | accessing array data inside of an array - I want to extract the name of the photo uploaded. print_r of $_FILES yields: Files: Array ( [picture] => Array ( [name] => DSC_1802-saoirse-riona.jpg [type] => image/jpeg [tmp_name] => /tmp/phpJTspHZ [error] => 0 [size] => 76096 ) ) ...
Sending an array from a form - Hello, How do I send an array from a form to another php page?I want to bundle up some data from form fields in an array and send them together like that. I must be missing something? Thanks Mike
Incoming data into array? - Hi, I'm opening a remote file on a regular basis, the data is in the following format and has a line feed of "0D 0A". The spaces are 20 in hex mode. 2006-07-26 22:00:03.000000 4.370996 51.656616 2006-07-26 22:00:03.000000 2.599964 49.286836 ...
Problem with links with form data - Less than 1% of my users say they can not open links like this: index.php?variable=value&variable2=value2 Is anyone aware of some firewall/security setting that would prevent people from clicking on such types of links?
Validating and Passing form data to Thanks Page - Hi all, SERIOUS newb here just beginning to look into php. I've tried a few solutions to my issue from snippets I've seen, but so far nothing has worked. In an attempt to stop email harvesting and SPAM issues (I get about 2,400 every 24 hours), I'm.... |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|