Resubmitting the same form is not working - javascript

I am making an HTML page "Login Pro.html". I am making such a page where just clicking on a link I can login to an account (say Facebook).
HTML Code:
Login to my Account
The Form input fields for Username and Password (The value attribute will be set using JQuery):
<input type="text" id="username" value="" />
<input type="password" id="password" value="" />
<input type="submit" id="loginButton" />
In the JQuery code, I am setting the values and submitting the form like this:
$("#loginLink").click(function()//when the link is clicked this will be executed.
{
$("#username").attr("value","My Username");//Setting value for the username
$("#password").attr("value","My Password");//Setting value for the password
$("#loginButton").click();//Submitting the form by implicitly clicking the submit button
});
In this case I am able to login into my account successfully and the "Login Pro.html"(From the Page I am doing all these) is opening in a new page (because I have set target="_new" and the form is being submitted and taking me to the Home Page of the Account I am logging in into, is opening successfully in the first page (tab). But when I am trying to login again through the "Login Pro.html" page, opened in the new tab, I am being landed to the same page i.e. "Login Pro.html" page instead of getting logged in (In short in the second instance I can't login). After closing this page, when I am opening the page again, the same saga continues i.e. I am able to login in the first instance, but not able to do so while trying in the new tab.
Can somebody help me in getting rid of this. Is this because, the page is already loaded?

The "name" attribute is missing in the inputs. Without name you are not sending anything.

Related

page reload with success message php

i am trying above but message is displayed on php page.instead of reloading on index page AND DISPLAY MESSAGE ABOVE SUBSCRIBE FORM ITS REDIRECTING TO PHP PAGE.You can check on test site link attached.Form is on index
page.I tried to reload page through jquery onload and onclick onsubmit but didn't worked.below are test which i did.
//form is on index.html page
<!-- your form here -->
<form action="forms/subscribe.php"id="form" method="post">
<input type="email" name="email" placeholder="Enter your Email">
<input type="submit" value="Subscribe">
</form>
//form is on index.html page
My php page
<?php
// My Code goes here form to email
header.location(Location: /index.html)
?>
You cannot use js variable values after reload. You need to do things without reloading the page means you just need to update the content and control your HTML tags.
The above example you mentioned. They are not reloading the page, they are getting values from input box then hide that div. After hiding the div they are showing another div with the information.
For your solutions you can do the same but remember to reset input values for every request.
You can do it in PHP with page reloads if you store a message in the session. At the top of each page make sure that the first line is
session_start()
Then on the page that receives the data set a session message
$_SESSION['message'] = 'Some Value';
Then on your page with the form you check to see if the session has a message. If it does, display it and then clear it.
if(isset($_SESSION['message']) {
echo $_SESSION['message'];
session_unset('message');
}
some silly syntax error
using onsubmit="alert()"
<script>
function alert() {
alert("Thank you for contacting us. We will be in touch with you very soon.!");
}
</script>
on subscribe pageheader('Location: /index?message=success');

Contact Form not allow to enter data inside fields

Have one big problem that dont can resolve myself, because it seems more complex that i can handle myself. I have Contact Form created, and inserted CSS class that trigger popup window, with contact form. But when contact form is loaded, it dont allow me to enter any data inside fields, because looks like it is locked in some way. For example:
when press "Contacto" button (from right on image) is opening this popup window taht contain phone number about customer, and also another button called "Enviar email" that when is pressed trigger a new popup that contain contact form. This is code from that button:
<form>
<input class="spu-open-1734" type="button" value="Enviar email" />
</form>
class spu-open-1734 is CSS class generated by Popupups plugin.
When Contact Form is loaded into popup, it dont allow to enter any content into fields, like fields are blurred, and not allowing to enter nothing. Example here
Its really weird, because if upper code is inserted into Wordpress page for ex. its working fine, and allow to enter data. See here on this test page.

reload jsp page after logout on back button click

In every page of mine, there is a logout option. When the user clicks this logout option, they get log out session.invalidate(); .When I press the back button, even if the session is invalidated, I get the previous page with all the contents in the input tag.How can I resolve this problem.I tried window.location.reload(),and many other options, but it's not working in here.\
My website is this. and credentials are. test123#gmail.com and pass is Amal123
you can copy and paste this code in every page of your site which clears the cached page.
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
if(session.getAttribute("some_token")==null)
response.sendRedirect("login/login.html");
%>
In logout you must be invalidating session so when you click back it would check the some_token attribute value in session and if not there it will redirect you to login page . But remember after login you are setting some_token attribute in session.
Before all pages you want to open only when session is active you have to put a filter that checks for session before your pages get open.
And on loguot you have to invalidate the current session.
And then your will be able to press back button but can not perform any funtionality
You can use a session attribute... for example when you log in, set a variable value to username e.g:
HTML
<form name="login" action="/login.jsp" method="post" >
<input type="text" name="username" >
<input type="password" name="password" >
<input type="submit" >
JSP:
String userName=request.getParameter("username");
request.getSession().setAttribute("username",userName);
Now On every page,add this code
<% if(request.getSession().getAttribute("username")==null)
response.sendRedirect("index.jsp");%>
Also, at the time of logout do not forget to remove the session attribute.
request.getSession().removeAttribute("username");
Try it and let me know.

Submit button with enter an url

I'm trying to create a bookmarklet, which captures the url of the current page, where the user is, puts this url into a text field of a form on a page and then submits the form by virtually pressing submit button.
With following code i get the url of the current page, go to the site with url http://example.com/?url=http://www.url-of-the-current-page, fill the url http://www.url-of-the-current-page into the form's text field, but the form itself remains unsubmitted:
javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href))})();
But how can i submit the form button? The whole form looks like:
<form ng-submit="launchTest()" class="ng-pristine ng-valid">
<input type="text" name="url" ng-model="url">
<input type="submit" value="Launch test" class="launchBtn" ng-class="{disabled: !url}">
</form>
I've tried two variants - and failed: in both variants i stay on http://example.com?url=http://www.url-of-the-current-page:
javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href));document.forms[0].submit()})();
javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href));document.forms[this.form.id].submit()})();
(Posted on behalf of the OP).
I've contacted the owner of the website, where I wanted to run my bookmarklet - he said, my bookmarklet is correct, but for submitting the form the url should contain a special parameter, like &run=1. With this parameter every bookmarklet mentioned in this thread works (works means not only opens new tab and inputs the url, but submits the form too). The working bookmarklet I'll use is:
javascript:(function(){var win=window.open('http://example.com?url='+encodeURIComponent(window.location.href )+'&run=1','_blank');win.focus();})()

Redirect the website URL Form to a particular Page

My Form Works Successfully But in website URL it only Shows the address to a Form.I have multiple Pages in which the Form button shown.All I want when a user click on The Form for Page A for that Particular page it should shown as
"www.form.com?test=page A" - this should displayed on website URL
or when the Form is submitted the receiver should view that this form coming from Page A..In the Form field I hidden this fields name 'Test' so the user cannot see it but only the receiver can view it that its coming from Page A
On my Html code I have redirected to the Build in Form.
Here is my java script code
<script type="text/javascript" src="http://test.com/form/y.php/test2"></script><no1script>Online Form - </no1script>
How to show it to my Website URL
I understand your question as "How can I redirect with a specific GET parameter?", correct me if I'm wrong.
The solution for that would be quite simple: Append the GET parameter to the forms action:
<form action="target.php">
gets
<form action="target.php?test=page_a">
so that on target.php if you evaluate the GET values, test has the value page_a.
If you're trying to hide the post data, you can try something like:
<form action="https://test.com/forms/discount" style="display:none">
<input type="text" name="couponCode" value="secret">
<input id="myform" type="submit">
</form>
<script>
document.querySelector("#myform").click();
</script>
Note: This won't stop any web ninjas, so you should think of something else, like web tokens that function sortta like private public keys.

Categories

Resources