473,396 Members | 2,020 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,396 software developers and data experts.

processing 2 things in one form. is it possible?

hi all,

i am creating a form that returns to itself like this:
<form name="form1" action="<?php echo $_REQUEST['PHP_SELF']; ?>"
method="post">

Upon clicking submit, I want the form to return to "itself" (does the
input fields validation). If the validation is false, the initial input
values are displayed on the fields. If the validation is correct, it
should go to an external file (on different server) and does the rest
of the processing such as sending mail or writing to a file, etc (could
be anything). There are basically 2 tasks here. Is this achievable in a
single form. I tried to include external file after validation but it
fails to call a function inside that file as the file resides on a
different server.

Can someone show me the right direction?

Thanks

Oct 4 '06 #1
3 1213

crescent...@yahoo.com wrote:
Upon clicking submit, I want the form to return to "itself" (does the
input fields validation). If the validation is false, the initial input
values are displayed on the fields. If the validation is correct, it
should go to an external file (on different server) and does the rest
of the processing such as sending mail or writing to a file, etc (could
be anything).
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
...show the form
}
elseif post
{
validate the post vars
if success
use the header() function to jump the external page
else
show the form again, you'll still have
the $_POST array hanging around to initialize
the form elements with, so the form looks
like it did just before the first submit
}

Oct 4 '06 #2

"pittendrigh" <Sa***************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>
crescent...@yahoo.com wrote:
Upon clicking submit, I want the form to return to "itself" (does the
input fields validation). If the validation is false, the initial input
values are displayed on the fields. If the validation is correct, it
should go to an external file (on different server) and does the rest
of the processing such as sending mail or writing to a file, etc (could
be anything).

if($_SERVER['REQUEST_METHOD'] == 'GET')
{
...show the form
}
elseif post
{
validate the post vars
if success
use the header() function to jump the external page
else
show the form again, you'll still have
the $_POST array hanging around to initialize
the form elements with, so the form looks
like it did just before the first submit
}
The only problem I see with that is that the OP probably wants to take data
along to the new script(on different server) and header won't do that by
itself afaik. You may need to use curl to repost your data to the other
server.
Oct 4 '06 #3
One solution is to use fsockopen to post the data to the other server.
Create a function which takes as input a URL to post to, and an array
of variables to be posted. This function could then connect the URL,
post the data, and return the response. Note that the response will
contain all data return from the server (including headers). Therefore,
the remote server's page should echo results in an easily parsable
form. I usually do something along the lines of:

<!-- OUTPUT STARTS HERE -->
<result>1</result>

This way you can easily cut off the headers, and look at the actual
result of the operation. Here is a code snippet of using fsockopen:

$request.="POST ".$URL_Info["path"]." HTTP/1.1\r\n";
$request.="Host: ".$URL_Info["host"]."\r\n";
$request.="Referer: $referrer\r\n";
$request.="Content-type: application/x-www-form-urlencoded\r\n";
$request.="Content-length: ".strlen($data_string)."\r\n";
$request.="Connection: close\r\n";
$request.="\r\n";
$request.=$data_string."\r\n";
$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp);

On Oct 4, 8:38 am, "Johnny" <removethis.huuan...@hotmail.comwrote:
"pittendrigh" <Sandy.Pittendr...@gmail.comwrote in messagenews:11**********************@m73g2000cwd.g ooglegroups.com...


crescent...@yahoo.com wrote:
Upon clicking submit, I want the form to return to "itself" (does the
input fields validation). If the validation is false, the initial input
values are displayed on the fields. If the validation is correct, it
should go to an external file (on different server) and does the rest
of the processing such as sending mail or writing to a file, etc (could
be anything).
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
...show the form
}
elseif post
{
validate the post vars
if success
use the header() function to jump the external page
else
show the form again, you'll still have
the $_POST array hanging around to initialize
the form elements with, so the form looks
like it did just before the first submit
}The only problem I see with that is that the OP probably wants to take data
along to the new script(on different server) and header won't do that by
itself afaik. You may need to use curl to repost your data to the other
server.
Oct 4 '06 #4

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

Similar topics

8
by: dmcconkey | last post by:
Hi folks, I have a client with four websites. Each site has a contact form that is identical. They all have "required" fields validated through a JavaScript onSubmit() function. Upon validation,...
6
by: Anders Søndergaard | last post by:
Hi, I'm trying to process a large filesystem (+20 million files) and keep the directories along with summarized information about the files (sizes, modification times, newest file and the like)...
8
by: Jimbo | last post by:
I'm working on a win app that reads and processes each line of an ascii file until the end of the file. Since the file's 1.6 million lines long, after a while Windows displays the "Not Responding"...
2
by: Luiz Vianna | last post by:
Hi folks, I got a problem that certainly someone had too. After a user request, I (my server) must process a lot of data that will expend some time. During this process I must inform the user...
10
by: CSDunn | last post by:
Hello, I'm having a problem with ASP.NET using IIS 5.1 on a Windows XP Pro machine. ASP.NET will not process the following code: ******************************* <html> <head> </head> <body>...
2
by: devendra pardeshi | last post by:
hi friends/seniors i am stuck on one problem in VB 6.0 and need solution. see if u can help me. first i describe the problem. Can u imagin the WinZip scenario. we right click on some file...
2
by: krgatez | last post by:
I've developed a Windows form application, and it takes a while to startup. Right now there is no indication that there is any activity. I'd like to establish some kind of hourglass, or processing...
10
by: Enrique Cruiz | last post by:
Hello all, I am currently implementing a fairly simple algorithm. It scans a grayscale image, and computes a pixel's new value as a function of its original value. Two passes are made, first...
3
clintw
by: clintw | last post by:
My problem. I have a html contact form that is being spammed. So I have set .html to be treated as .php, in order to include php image verification into the form. However, the Action on the 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.