Forum Moderators: coopster

Message Too Old, No Replies

Trying to run two functions on one click

         

scalp8

4:39 pm on Jan 14, 2009 (gmt 0)

10+ Year Member



else if ($step == "4") {
$message= $objU->register_step_three($_SESSION['register_id']) AND $message= $objU->register_freecode(addslashes(FREE), $_SESSION['register_id']);
if ($message <> "")
$step= $step-1;
else {
if ($_SESSION['steps'] < $step)
$_SESSION['steps'] = $step;
header("Location: register_success.php");
exit();

I've tried replacing the "AND" with a semicolon. All that did was call the second function only. With the "AND" it only calls the first function. Is there any way to call them both or do I have to insert the second function into the first and have it called that way?

scalp8

6:51 pm on Jan 14, 2009 (gmt 0)

10+ Year Member



FIXED: I just inserted the second function into the first. Works well. Still curious if there is a way to call two functions at once though.

coopster

8:06 pm on Jan 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What exactly do you mean by "at once" in your question?

scalp8

8:20 pm on Jan 14, 2009 (gmt 0)

10+ Year Member



My question refers to this line:

$message= $objU->register_step_three($_SESSION['register_id']) AND $message= $objU->register_freecode(addslashes(FREE), $_SESSION['register_id']);

I put the function register_freecode inside of the register_step_three to make this work so the line just reads like this now:

$message= $objU->register_step_three($_SESSION['register_id']);

Is there a way to make it work as I was trying to in the first example? I may not be phrasing the question correctly. I was trying to cause the click of the "submit" button to call two functions instead of one function that contained both.

coopster

8:37 pm on Jan 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Well, it depends on what you need returned. It looked at first as if you needed return values from both. If not, just call the functions:
else if ($step == "4") { 
$objU->register_step_three($_SESSION['register_id']);
$objU->register_freecode(addslashes(FREE), $_SESSION['register_id']);
}

Otherwise, call one, then the next ...
else if ($step == "4") { 
$message = $objU->register_step_three($_SESSION['register_id']);
if ($message) {
$objU->register_freecode(addslashes(FREE), $_SESSION['register_id']);
}
}

You would have to determine the logic in regards to the $message variable, but hopefully this helps get you started.

scalp8

9:36 pm on Jan 14, 2009 (gmt 0)

10+ Year Member



Thank you very much!