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..............

Recommended Answers

All 7 Replies

u can use

onclick="history.go(-1);"

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

will i works

you can use button names to differentiate:
means:

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

then you can use the buttons in php code:

if(isset($_POST['submitbutton']))
{
//insert queries
//header("one.php");
}
if(isset($_POST['backbutton']))
{
//header("one.php");
}

Hi,

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.

Thanks!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.