prevent page refresh on php while I click browser back option [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have a form created in HTML.the form values passed second page via post method.in that page I put the edit button while I click that button to redirect the HTML form page with user typed values.now my problem is how to prevent the page reloaded in PHP or JAVASCRIPT

You can use the Post/Redirect/Get pattern.
When the form is submitted as a POST request, your PHP scripts sends a redirect response to the client, which causes the result to be fetched with a new GET request.
This avoids the resubmit of a form when the refresh button is pressed.

You can do this with JavaScript using window.history.
See Manipulating the browser history
However, your original form should get the saved values from a database. There's no guarantee that sending the user back a page will not cause the page to reload. It depends on the browser.
If this is your edit button
<button id="editButton">Edit</button>
Then your JS would look something like:
document.getElementById('editButton').onclick = function(event){
event.preventDefault();
window.history.back();
return false;
}

Related

Place Cookie to prevent re-visiting site [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a contest site, I want it to prevent people going on it when they have submitted the form on the page. Is this possibe?
Thanks
You could build system where users are required to enter their email address, and enter a verification code which is sent to them. But they would only be able to enter this verification code once. Therefore, the only way of cheating would be to use two separate email addresses (and they would have to have access to both).
Cookies would not be the best option for this as anyone could clear their cookies.
It's not necessarily possible to stop users requesting a page, however you can either redirect them to another page or show some kind of error message to them, to tell them that they can't resubmit.
Presuming you have some kind of user registration in place already (and are tying competition entries to those users with an ID) then all you would have to do is check for the existence of a competition entry in the database and then, if one is found, either force a redirect (likely in <script> tags) or replace the rendering of the page with the notice that you can't resubmit.

Do I need submit buttons with ajax applications [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Posting data to the server needs a form-tag.
But do I also need a button of type 'submit' when I use ajax/jquery?
Can I not just interrupt the button click and do my own ajax request?
No, and technically you don't even need a form tag if you want to serialize the POST data yourself.
If you are using Ajax then you don't technically, need a form tag or a submit button.
Having them gives you convenient, semantic elements with logical events to bind the JavaScript to.
Having them is needed for the JS to be unobtrusive (which is a best practise).

Submit a Form with Validations using AJAX and PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have a PHP page with Session set on that page . I want to add a form with validations which contains dropdown list(the list displays all projects assigned to employee depending on the empid retrieved from session variable).This form will be processed and the Project selected will be traced so that the employee starts his work on that project.
I want a functionality which will show that the Project has been tracked and rest of the contents should not be refreshed.Only the form should be processed and return the result (as everything has session working and the page is to be accessed only once)
These links may help.
Submit a form with Ajax and jQuery:
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
Validate a form:
http://jqueryvalidation.org
Use jQuery Form Plugin
http://malsup.com/jquery/form/#ajaxForm
I think this will solve your purpose

PHP Redirect on Submission Based on Different id/URL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am looking for a PHP Script that can redirect users to specific and different URLS when they hit "Submit" button.
I can afford to have the URL Like
www(.)mydomain(.)com/form.php?id=www(.)rediectedurl(.)com
Now if the user clicks submit button it redirects him/her to www.redirecturl.com. So for multiple posts i can easily change the URL and it redirects differently?
I hope anyone can answer it.
Thanks
First you'll need to escape the "URL" types of characters in your domain.com URL so that PHP can properly read the second one as a parameter. So if you wanted to redirect to www.redirect.com?foo=bar, your main URL would look something like:
www.mydomain.com/form.php?id=www.redirect.com%3Ffoo%3Dbar
Now, form.php needs to do several things:
Read the parameter
Unescape it
Use PHP's built-in header() function to set the "Location" header to the unescaped parameter
Example: header("Location: www.redirect.com?foo=bar");
Hope that gets you started.

HTML Message Sender [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I am trying to make a button that will allow me to send a preset message to an email address. I don't want it to be a form, or an email tab that sends the message. I just want to be able to click a button, so that I can send this premade message. Is there any way that I could do that?
This may not be the exact answer you're look for, but an easy alternative would be:
Send Message
Make sure you replace spaces with %20
You can add an <a> tag with a mailto: href:
<a href="mailto:someone#somewhere.com?subject=your subject&body=your message">
Click here to email me</a>
Yeah, but you're going to need some sort of backend, like Python, .NET, Rails, or PHP. When you click the button, it would have to be either a link or a form submit button that sends a request to some backend page that handles actually sending the email.
Each backend has its own specific way of doing this. You would need to specify which language you wish to use for anyone to provide further help.
You would need to write a serverside script to send the email. Your button could fire an AJAX request to the serverside script to send the email that way.
Unfortunately there is no way to send emails strictly using HTML or javascript (with Node being the exception).

Categories

Resources