-2

I understand that it validate form data on the same page, but what if i want my form data to be handled by example.php can I use PHP_SELF and example.php together on some condition?

Rana Ghosh
  • 4,514
  • 5
  • 23
  • 40
Iyayi Eddy
  • 37
  • 6

1 Answers1

0

If you want to submit your form to the same page, i.e. PHP_SELF when a condition is met and submit it to example.php when a different condition is met, then try this:

<form method="POST" 
  action="<?php echo $some_condition == "some_value" ? $_SERVER['PHP_SELF'] : 'example.php'  ?>">
...
Your form content here
...
</form>

You will replace $some_condition == "some_value" with whatever condition you want to check.

k32y
  • 407
  • 6
  • 11
  • thanks alos @k32y . again please can you help me with this, am getting this error Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\Documents and Settings\Eddyboy\My Documents\Downloads\xampp-win32-1.7.2\xampp\htdocs\registern.php:1) in D:\Documents and Settings\Eddyboy\My Documents\Downloads\xampp-win32-1.7.2\xampp\htdocs\registern.php on line 3 – Iyayi Eddy Jun 08 '17 at 05:48
  • `session_start()` has to be called before you print any output to the screen. if possible let it be the first statement in your script. You are getting that error probably because your script threw an error somewhere and the error message is printed before your `session_start()` statement is executed. – k32y Jun 08 '17 at 08:55
  • @IyayiEddy were you able to solve the problem? If so accept this answer if it helped you or provide the solution that worked for you to help others that might face the same issue. – k32y Jun 13 '17 at 07:55