Page 1 of 1

Redirection after script complete.

Posted: Sat Oct 17, 2009 10:03 am
by synical21
Hello Experts.

I have a problem with redirection using php. Basically when a user clicks this button they are taken to "proofprocess.php" which is a series of MySQL calculations changing user values.

I want to queries to run then direct back to the page the user was last on. I done it like this

Code: Select all

 
<?
  
     
 $sql = "SELECT `proof`.*,
        `users`.*
   FROM `proof`,`users`,`fulldata`
  WHERE users.id = $id
    AND proof.userproof_id = $id
    AND proof.job_id = $_GET[jid]";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
     
     $sql = "UPDATE `users`,`proof`
    SET clickstatus = 1
  WHERE proof.userproof_id = $id
  AND proof.job_id = $_GET[jid]";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
  
 $sql = "UPDATE `users`,`proof`
    SET user_earning = user_earning + perperson
  WHERE users.id = $id
  AND proof.job_id = $_GET[jid]";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
  
  
 $sql = "UPDATE `users`
    SET jobs_completed = jobs_completed + 1
  WHERE id = $id";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
     
 
 
header( "Location: http://www.myurl.com/jobproof.php?ID=$_REQUEST[jid]") ;
?>
Although it appears to be redirecting back to the last page the queries are not being run so no values are being changed. Any guidence please?

Re: Redirection after script complete.

Posted: Sat Oct 17, 2009 12:08 pm
by califdon
Try:

Code: Select all

header( "Location: http://www.myurl.com/jobproof.php?ID=".$_REQUEST['jid']) ;

Re: Redirection after script complete.

Posted: Sat Oct 17, 2009 5:34 pm
by synical21
Thank you it works :) :drunk:

Re: Redirection after script complete.

Posted: Sat Oct 17, 2009 6:42 pm
by califdon
You're welcome. Glad it resolved your problem. Only simple $variables are interpreted within double quotes. Arrays, functions, etc. are not, so you have to concatenate them with the rest of the string. Also, array indexes (that's what the part inside the square brackets is) must be quoted strings or variables.