Hi,
What i'm trying to do, may not be possible. but i just wanted to know if there is a way of doing this.
Basically what i am trying to achieve is to call the previous php script that was run before the currenttly executing script
e.g.
if page 'A.php' has a form in it, which has its data posted to page 'B.php'. I want page B.php to do some validation, on the posted data. and based on the results of this validation. I want page B.php to call up page A.php with all the posted variables that were posted to page B.php passed back to page A.php
Thanks in advance.
8 1495
In A.php, set <form> action to B.php. After validating use header() to redirect to A.php and to keep data use sessions.
Make sure you do not create an ifinite loop.
And If you like you can use One script to do the same job as A and B.
Thanks!
And If you like you can use One script to do the same job as A and B.
Though this is generally not a good idea as it tends to break MVC, creates odd behavior when the User refreshes the page in his browser and encourages interweaving PHP and HTML code (which results in difficult-to-read code and misconceptions in how PHP works [e.g., "How do I call a PHP function using JavaScript?"]).
Seriously, you should just post to the same page. It simplifies life and actually makes sense. :P
Hi,
What i'm actually trying to do is build a CAPTCHA for an online form.
I thought about posting to the same page, but this page is already quite large with lots of programming code. Meaning that in future if another developer were to go through the code, they will have a pretty hard time tryin to understand whats already happening on the page.
Also page B.php will not know which page sent it the posted data, so i can't hard-code that into the header(), i plan to have lots of script posting to this page (B.php) in other to check the captcha.
But i think i'm going to have to post to the same page, becuase can't see any other alternative.
Heya, nitinpatel.
Also page B.php will not know which page sent it the posted data, so i can't hard-code that into the header(), i plan to have lots of script posting to this page (B.php) in other to check the captcha.
Check out $_SERVER['HTTP_REFERER'].
Thats great phmods, i can't believe that i didn't find that server variable myself.
Anyway, i assume that theres probably one for the posted variables as well, time for some more documentation reading i think
Heya, nitinpatel.
One popular method for sharing data between two pages is to use the Session. Often, you'll see something like this at the top of some pages: -
foreach($_POST as $key => $val)
-
$_SESSION[$key] = $val;
-
There are better ways of doing it, but this code will do the job.
Add that to the top of page b (the one that does the data processing). Then, if there are errors, you can redirect the User to the form without having to pass variables back and forth.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bill |
last post by:
Does ASP have a file whose function is similar to .htaccess on Apache? I'm
looking to protect subdirectory content.
|
by: Jeff |
last post by:
Hello all,
I've created a COM dll for a number-crunching program. However when I tell
the program what function to use from the DLL, it claims that it cant find
the function.
I have the...
|
by: Nick Palmer |
last post by:
Hi all,
Is there a DB2 equivilant to Oracle's DB Link functionality ? I have two
DB2 databases and I need to get access to the tables in one from the other.
In Oracle I would just create a DB...
|
by: Shagy |
last post by:
Greetings,
I've been trying to find an equivant c funtion to the c++ copy function.
Description:
copy(char *cstring, size_t count, size_t offset);
Copies "count" characters from a C-style...
|
by: Trint Smith |
last post by:
This is how I did this sql server 2000 string in vb.net:
"FROM TBL_TravelMain WHERE TravelMain_Mlv = '" & MLVTrimString & "'"
In C# you can't use the & something &.
How do I put this in C#,...
|
by: moondaddy |
last post by:
What's the .net framework equivalent of the vb function isnumeric? If there
isn't one, how can I test a string variable to see if its a number or not?
I don't want to use isnumeric if possible
...
|
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= |
last post by:
I am writing an application that automates running sql scripts against my
database. Currently, I am using Process.Start("sqlcmd") with a number of
parameters to accomplish this, but I would like...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |