473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Form Data -> Variables or an Array?

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.
Sep 26 '06 #1
4 2243
"Cerebral Believer" <no**********@hadenoughalready.comwrote in message
news:xf*****************@newsfe7-gui.ntli.net...
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
Sep 26 '06 #2
"Ron Barnett" <ro*@RJBarnett.co.ukwrote in message
news:4519295e.0@entanet...
"Cerebral Believer" <no**********@hadenoughalready.comwrote in message
news:xf*****************@newsfe7-gui.ntli.net...
>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.
Sep 26 '06 #3
"Cerebral Believer" <no**********@hadenoughalready.comwrote in message
news:l_*******************@newsfe2-gui.ntli.net...
"Ron Barnett" <ro*@RJBarnett.co.ukwrote in message
news:4519295e.0@entanet...
>"Cerebral Believer" <no**********@hadenoughalready.comwrote in message
news:xf*****************@newsfe7-gui.ntli.net...
>>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
Sep 26 '06 #4

"Ron Barnett" <ro*@RJBarnett.co.ukwrote in message
news:4519593c.0@entanet...
"Cerebral Believer" <no**********@hadenoughalready.comwrote in message
news:l_*******************@newsfe2-gui.ntli.net...
>"Ron Barnett" <ro*@RJBarnett.co.ukwrote in message
news:4519295e.0@entanet...
>>"Cerebral Believer" <no**********@hadenoughalready.comwrote in message
news:xf*****************@newsfe7-gui.ntli.net...
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.
Sep 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
9
by: cooldv | last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this code: message = Replace(usermessage, "'", "''"). My problem is DISPLAYING data in an asp FORM, from an an access database,...
2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.