Jump to content

Call a Script?


CWeaver

Recommended Posts

Can I invoke a php script from the server as a href would be from the client?

if (thisIsTrue){   RunThisScript.php?var=Stuff;}else{   RunThisScript.php?var=OtherStuff;}

I can call functions OK, but I can't figure out how to redirect the process to another script, abandoning the one I'm in altogether. Can it be done? Seems really old school in a way, but I would like to know anyway.

Link to comment
Share on other sites

I'm not sure if this is exactly what you want to do but there are two/three joices. 1st, you could use javascript. The code in the if would be:print"<script>location.href="runthisscript.php?var=$stuff"</script>";This would change the location of the whole page, if that is what you wanted. You could also use the PHP require. The code in the if would be:require("runthisscript.php?var=$stuff");The problem with this would be that the code, whether or not the if is true would load. To solve this you could use ajax (I am currently learning ajax, so I can't really help with that). If I were you I would use the javascript method. The webpage location will change to the script you put in, and your variable would be passed and could be retrieved using GET. The only draw back to using javascript is that you would have to design visually something to be displayed on the script that is run (other wise, if you just for example send an email in that script you would only see white space). If you want to stay in the same webpage (and not load the information automaticaly whether it is used or not) then use ajax.axel

Can I invoke a php script from the server as a href would be from the client?
if (thisIsTrue){   RunThisScript.php?var=Stuff;}else{   RunThisScript.php?var=OtherStuff;}

I can call functions OK, but I can't figure out how to redirect the process to another script, abandoning the one I'm in altogether.  Can it be done?  Seems really old school in a way, but I would like to know anyway.

[/CODE][CODE]

Link to comment
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
×
×
  • Create New...