0

So on a PHP page (page 1) I have some HTML, including :

<form action="create_subject.php" method="post" >

Which goes to a processing page (page 2) containing MySQL which will be executed if there aren't any errors. If there are (checked by validation on the processing page (page 2)) or aren't, certain variables are set, including this one for if it's successful :

if (mysql_affected_rows() == 1){
   $success = 1;
   redirect_to("new_subject.php");
}

However, how would I include $success into the URL without putting it in as :

   redirect_to("new_subject.php?success=1");

I can't do this as I need to do if statements, and it's only PHP on "page 2" so I can't do an if statement inside

redirect_to("new_subject.php");

I know I could do

...
} else {
redirect_to("new_subject.php?success=1");
}

But this would seem mundane and non-semantic especially as I have several variables to proccess.

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
user1228907
  • 369
  • 2
  • 6
  • 16
  • Please take a look at [this question](http://stackoverflow.com/questions/3045097/php-redirect-and-send-data-via-post). –  Mar 25 '12 at 17:26
  • a roughly idea: putting the relevant variables in an assoc. array and do an array_explode() to generate the query string. Needs to be granulated of course. – Daxcode Mar 25 '12 at 17:27

1 Answers1

0

i dont know why you wont put it like success=1 in the url since it is the easiest way to do it but you could do something like new_subject.php?success_1 then go

$url = explode("_", $_SERVER['QUERY_STRING']); //get an arry
$one = $url[1];
Khalid
  • 194
  • 1
  • 1
  • 7