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

Calling External File

I am fairly new to PHP programming, and I'm trying to get my head around
this one...

I have a form that I am doing validation on via PHP within the same page, so
if there is an error, a message will show to the user above the form. If all
goes well, I would like to call a processing script that I have already set
up and working to format the users response and send it out to a specified
e-mail... I'll call it processing.php

Is there a way that I can, if the form is filled out correctly, make a call
to processing.php, that will totally leave the control of form.php and do
it's processing?

I hope I'm making myself clear...
Thanks.

--
SamMan
Rip it to reply

Jul 17 '05 #1
7 2520
SamMan schrieb:
Is there a way that I can, if the form is filled out correctly, make a call
to processing.php, that will totally leave the control of form.php and do
it's processing?
header('Location: http://www.example.com/processing.php');
exit;
I hope I'm making myself clear...


I'm not sure ... ;-)
Regards,
Matthias
Jul 17 '05 #2
"Matthias Esken" <mu******************@usenetverwaltung.org> wrote in
message news:cd**********@usenet.esken.de...
SamMan schrieb:
Is there a way that I can, if the form is filled out correctly, make a call to processing.php, that will totally leave the control of form.php and do it's processing?


header('Location: http://www.example.com/processing.php');
exit;
I hope I'm making myself clear...


I'm not sure ... ;-)
Regards,
Matthias

The problem is that if I use the header method from within the first page
(form.php) I get an error that the headers have already been sent, or
something to that effect.... At least this is what I recall was happening
yesterday. I will give it a try again, and let you know.

Thanks.

--
SamMan
Rip it to reply
Jul 17 '05 #3
SamMan wrote:
I am fairly new to PHP programming, and I'm trying to get my head around
this one...

I have a form that I am doing validation on via PHP within the same page, so
if there is an error, a message will show to the user above the form. If all
goes well, I would like to call a processing script that I have already set
up and working to format the users response and send it out to a specified
e-mail... I'll call it processing.php

Is there a way that I can, if the form is filled out correctly, make a call
to processing.php, that will totally leave the control of form.php and do
it's processing?

I hope I'm making myself clear...
Thanks.

basically use hidden flag fields to tell you when everything is okay

if (isset($flag))
{
form method=post) // using no method says to use this file
<input type=hidden name=flag value=1>
fill in the form and if it is incorrect have them make corrections
if no corrections needed, then add a hidden field called okay
form with all correct variables action=processing.php
} else
{
form method=post) // using no method says to use this file
<input type=hidden name=flag value=1>
other input fields
submit


--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #4
"Matthias Esken" <mu******************@usenetverwaltung.org> wrote in
message news:cd**********@usenet.esken.de...
SamMan schrieb:
Is there a way that I can, if the form is filled out correctly, make a call to processing.php, that will totally leave the control of form.php and do it's processing?


header('Location: http://www.example.com/processing.php');
exit;
I hope I'm making myself clear...


I'm not sure ... ;-)
Regards,
Matthias

The error that I'm getting is "Cannot modify header information - headers
already sent...". Unless I put it at the very top of the page, then it
works. This will be another challenge, as I will need to put the validation
code at the top of the page (I'm assuming) and I would like any errors to be
displayed in a specific location in the form.

Back to work!
Thanks.

--
SamMan
Rip it to reply
Jul 17 '05 #5
"Matthias Esken" <mu******************@usenetverwaltung.org> wrote in
message news:cd**********@usenet.esken.de...
SamMan schrieb:
Is there a way that I can, if the form is filled out correctly, make a call to processing.php, that will totally leave the control of form.php and do it's processing?


header('Location: http://www.example.com/processing.php');
exit;
I hope I'm making myself clear...


I'm not sure ... ;-)
Regards,
Matthias

Matthias,

I think I have this sorted out. Doing a test page...
All the validation code is at the very top of the document, before anything.
This code checks for errors and sets a flag. If there is no error ($flag=
="false"), the processing script is called (using the header() function). In
the location that I want the error's to display, the flag is checked, and if
true, the errors displayed. Of course, this is a very simple test of the
logic.

I believe I will be able to easily transfer this logic to the form at work.

Thanks for stimulating my brain!
--
SamMan
Rip it to reply
Jul 17 '05 #6
SamMan wrote:
I think I have this sorted out. Doing a test page...
All the validation code is at the very top of the document, before anything.
This code checks for errors and sets a flag. If there is no error ($flag=
="false"), the processing script is called (using the header() function).


That's the way I write my scripts. :-)

Regards,
Matthias
Jul 17 '05 #7
"Matthias Esken" <mu******************@usenetverwaltung.org> wrote in
message news:ce*********@usenet.esken.de...
SamMan wrote:
I think I have this sorted out. Doing a test page...
All the validation code is at the very top of the document, before anything. This code checks for errors and sets a flag. If there is no error ($flag= ="false"), the processing script is called (using the header()
function).
That's the way I write my scripts. :-)

Regards,
Matthias

I ended up doing it a little different....
Everything is still at the top of the doc, and a flag is set on error, but
if none, the processing (formatting of the e-mail message) is done right
there. If the message is sent successfully, then a header function is used
to redirect to a thank you page, if not, an error page.

I even took it a step further. I have made as much of the scripting into
includes as I could. I tried to separate the error checking & processing
into two separate includes, but it didn't like that, so I just made one
include. Any error message that is to be displayed is handled by an include
also. This makes for a much cleaner looking page, and helps separate the
view from the model.

Thanks again!

--
SamMan
Rip it to reply
Jul 17 '05 #8

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

Similar topics

5
by: Ben | last post by:
hi all, just wondering if it is possible to call a function that resides on external php file before any <html> tag?? i have a code that sets a cookie which needs to be called before <html> tag....
11
by: Jake j | last post by:
Yes, this is a simple and straightforward thing to do as long as the .js file doesn't use a function. When I try a script with a function in a js file I can't get it to work (though it works fine...
4
by: Sivakumar Shanmugam | last post by:
Group.. We are running on db2 UDF V8 on Sun solaris platform. I created an UDF which calles a C-routine(SQL_API_FN). This C-routine in turn calls an external C-function. The C-function is provided...
5
by: claus.hirth | last post by:
If I create the function HELLO in schema S01 as follows, @ CREATE FUNCTION S01.HELLO() RETURNS VARCHAR(32) EXTERNAL NAME 'UDFSRVXYZ!sayHelloWorld' LANGUAGE JAVA PARAMETER STYLE DB2GENERAL NO...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
11
by: j23 | last post by:
I have library (static) testlib.cpp: #include <stdarg.h> void xxx(...) { char buf; va_list args; va_start(args, buf); va_end(args); }
11
by: RichN | last post by:
I am developing a c program in Visual Studio .NET 2003. I also have an Intel(R) Fortran compiler for MVS .NET My fortran sourcecode already existed. I started a new fortran project and chose to...
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
5
by: Newbie Coder | last post by:
Hello all I have 3 functions in a javacrip file (MyScript.js), which is added to an ASP.NET 2.0 project 1) no right-click 2) no select text (copy...) 3) History.Back()' How do I call...
47
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.