Hi all,
I have two buttons, submit and back......after clicking the submit it will go to the action part,
but i have another button back , if i click on the submit it has to go to previous page so how to do. as i think we can only one action for button, here i have two what to do how to proceed.
help me out..............

else u can use

first another form name as form2 and use the code

<form action="lastpage.php" ><!--- Your values or code ---></form>
onclick ="form2.submit();"

what does it mean

action="<? $_SERVER ?>

<form id="form2" name="cusregistration" method="post" 
								   action="<? $_SERVER['PHP_SELF'] ?>" onSubmit="return validatecr(this);">

action="<? $_SERVER['PHP_SELF'] ?>

means this page is submitted on the same page the url of the page is not change

like u r on page xyz.php and after submitting the form page will be xyz.php

you can use button names to differentiate:

<input name="submitbouttn" type="submit">
<input name="backbutton" type="submit">

then you can use the buttons in php code:

//insert queries


It seems you have got two different questions here.

1. How to go back.
Here, you can either use two forms as suggested above, Using javascript is not recommended. Another solution would be to use image links. This solution is recommended if your website has customised buttons which is very much likely. All you have to do is to populate the reference of the previous page on the current page. To learn more about image links please visit http://tutorialindia.com/html/html_image_links.php

2. onSubmit="return validatecr(this)"

Here, the javascript function validatecr is called to validate the form when submit button is pressed. The validatecr function must return a value true or false. If the validation fails, the validatecr function should return false which is again returned to the browser. In this case the browser will not submit the form. If everything is fine then the validatecr function returns true and the form is submitted to the same page.

You can confirm this by observing your PHP script. The form elements would be retrieved using the $_GET, $_POST or $_REQUEST methods.

See the validatecr function to confirm that it return true or false depending on the validation.

Please do not forget to mark the question solved if query is resolved.


References: http://tutorialindia.com/php/php_get_array.php