473,386 Members | 1,779 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,386 software developers and data experts.

PHP equivilant to the javascript back

111 100+
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.
Jul 6 '07 #1
8 1495
mwasif
802 Expert 512MB
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.
Jul 6 '07 #2
ak1dnar
1,584 Expert 1GB
And If you like you can use One script to do the same job as A and B.
Thanks!
Jul 7 '07 #3
pbmods
5,821 Expert 4TB
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?"]).
Jul 9 '07 #4
kovik
1,044 Expert 1GB
Seriously, you should just post to the same page. It simplifies life and actually makes sense. :P
Jul 9 '07 #5
nitinpatel1117
111 100+
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.
Jul 9 '07 #6
pbmods
5,821 Expert 4TB
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'].
Jul 9 '07 #7
nitinpatel1117
111 100+
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
Jul 9 '07 #8
pbmods
5,821 Expert 4TB
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:
Expand|Select|Wrap|Line Numbers
  1. foreach($_POST as $key => $val)
  2.     $_SESSION[$key] = $val;
  3.  
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.
Jul 9 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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.
4
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...
63
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...
27
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...
6
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#,...
8
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 ...
5
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...
0
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,...
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: 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$) { } ...
0
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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
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...

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.