Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Transfer Variables To Another Php Script

Recommended Posts

Hello,I've one registration page where the users fills in their information, is it possible to trasnfer the things the fill in on the registration page to another script that does someting and returnes something to the first page like true/false and then the registration gives an error messange if the other php script returned false?Something like the script "activates" another script that does something and returnes the result back to the original script.Best Regards

Share this post


Link to post
Share on other sites

Could you use a class? I'm not very experienced with classes in PHP, but would this work for your purposes?

(your first script)

include helperclass.php;$result = Helper::activate($var1, $var2, ..., $varN);
(helperclass.php)
class Helper {     function activate($var1, $var2, ..., $varN) {          if(...)               return true;          else               return false;     }     function otherStuff($var1, $var2, ..., $varN) {          ...     }}

Share this post


Link to post
Share on other sites

Something like the script "activates" another script that does something and returnes the result back to the original script.

 

Sounds like you're talking about a form that submits to itself. Basically, the values will be captured by using the $_POST['formElementName'] and then you check to see if the form has been submitted already with if ($_SERVER['REQUEST_METHOD'] == "POST"). If it hasn't been submitted yet, you display the form, if it has you display something else.

Share this post


Link to post
Share on other sites

i think that registering a session variables is easier, you can save the entered data from the user into a session variable then in any page you should write:

session_start();
then all the session variable will be defined.

Share this post


Link to post
Share on other sites

I would suggest simply including (via 'include()') the script from wherever the form is sending its data ('action="page"'), as has more or less already been mentioned.Depending on the method you instruct the form to use - ie. POST or GET - data entered in the form will be stored in either the $_POST or $_GET arrays respectively once it is submitted. So if you were to include() your script from the page that receives the data, the two abovementioned variables would be accessible.

Share this post


Link to post
Share on other sites

Using sessions is not always an option. Nor is it always desired. I try to avoid using cookie or session data wherever I can, and only ever do so if there is absolutely no other option.PHP often appends the session ID to URLs where it has no other option for 'remembering' the session owner, meaning a link to, say, '/file.php' may become '/file.php?PHPSESSID=(some 32 byte MD5 hashed string)'. This is not only problematic when someone bookmarks or links to a certain page on your website, inadvertedly including the session ID, but also when search engines attempt to crawl your site. I seem to vaguely remember Google advising against the usage of sessions where possible due to the latter reason.If you need to use data later, I would suggest storing it in a database (even a flatfile will do the trick where no other option is available). Remember that any files include()ed will have access to all variables declared on a global scope (such as $_POST), meaning that if the form submits data to 'page.php', and 'page.php' references 'script.php' via include() or require(), script.php will be able to access and manipulate the data received. If the information is not 'valuable' (for lack fo a better word) enough to store in a database, then you probably don't need to remember it outside of immediate processing anyway.

Share this post


Link to post
Share on other sites

How to transfer variable from one page to another in php?

Transfer Variables To Another Php Script

 

I am going to make a login page. After my login I want to print username in in another page. How will I do?

 

-Imtiaz Alam Khan

Share this post


Link to post
Share on other sites

script driven self-submiting form

Transfer Variables To Another Php Script

 

Hi, was looking for a way of writing a php script that would cause a form to submit itself after a timer expires. Thanks.

 

-question by koros

Share this post


Link to post
Share on other sites
php/mysqlTransfer Variables To Another Php Script

I want to a offline grid example and a script.

-question by sanjaya

Share this post


Link to post
Share on other sites
Script driven self-submiting formTransfer Variables To Another Php Script

koros-

This is actually a javascript function. The code would be:

setTimeout( document.Formname.Submit(), 1000); //second parameter is time in milliseconds

-Reply by Owen

Share this post


Link to post
Share on other sites

hello sirs, I am using wamp server 2.0. I have managed to display records on the webpage through php query. Now that my records are temporarily available on the page in a table, I have made a hyperlink against every record. I want that whenever the link is clicked on, the information in that particular record should be transferred onto another form in a different page. I am having problem in this regard. If you people can guide me, I shall be thankful. Take care!

-question by Malik

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.