cian
Technical User
- Oct 11, 2001
- 1,383
Hi guys,
i'm working on my first script (form processing script), reworking anyother script which I have.
I have one piece which I know what it does but I have no idea how to take it apart.
What I want to do is
1. understand what the heck is happening
2. separate the code into 2 seperate parts
The piece of code i'm stuck on is:
if ($required) {
$ra=explode(",", $required);
$num=count($ra); }
$results="";
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
if (($key!="sendto"
&& ($key!="reply_from"
&& ($key!="reply_fromaddr"
&& ($key!="reply_subject"
&& ($key!="reply_message"
&& ($key!="subject"
&& ($key!="required"
&& ($key!="redirect"
) {
for($i=0;$i<$num;$i++) {
if (($key==$ra[$i]) && ($val==""
) DIE ("<html><script language='JavaScript'>alert('Please fill in the $ra[$i] field!'),history.go(-1)</script></html>"
; }
$results.="$key: $val\n"; }}
i THINK it does the followig
- check what form fields are required and alerts the user to fill them in
- check's what form fields are defined in the script and submits any other form fields as $results
Can you help me break this code down?
The problem i'm stuck on in the script is making it generic so that all form fields are submitted, BUT some fields will be defined in the script so I can't have those repeated.
Think you can help??
É ::
i'm working on my first script (form processing script), reworking anyother script which I have.
I have one piece which I know what it does but I have no idea how to take it apart.
What I want to do is
1. understand what the heck is happening
2. separate the code into 2 seperate parts
The piece of code i'm stuck on is:
if ($required) {
$ra=explode(",", $required);
$num=count($ra); }
$results="";
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
if (($key!="sendto"
for($i=0;$i<$num;$i++) {
if (($key==$ra[$i]) && ($val==""
$results.="$key: $val\n"; }}
i THINK it does the followig
- check what form fields are required and alerts the user to fill them in
- check's what form fields are defined in the script and submits any other form fields as $results
Can you help me break this code down?
The problem i'm stuck on in the script is making it generic so that all form fields are submitted, BUT some fields will be defined in the script so I can't have those repeated.
Think you can help??
É ::