Form dosnt go to action address - html

I have a problem. I have two forms in a web page that are different action but one of my form don't work.
<form name="loginform" id="loginform" action="./loginAction.php" method="GET" class="login-form">
<input type="hidden" name="action" value="login">
<div class="form-group">
<label class="sr-only" for="form-user">Username or Email</label>
<input type="text" name="uname" placeholder="Username or Email..." class="form-user form-control" id="form-user" required>
</div>
<div class="form-group">
<label class="sr-only" for="form-pass">Password</label>
<input type="password" name="upass" placeholder="Password..." class="form-pass form-control" id="form-pass" required>
</div>
<button name="loginBtn" value="login" type="submit" class="btn">Sign in!</button>
</form>
even in submit dosn't redirect to action page
you can see in this url

There is no problem in you html code as well as javascript code.
Its your server code which is redirecting back to the login page . As you are using get the data should be visible in the url. When the form is submited the data cleans because its redirected to the login page. SO if you provide the server code we can have a look to it

From a first look i think if you want to submit data with a form you need to set method="post"

Related

New to coding. Having trouble with an email form on my portfolio webpage

I'm trying to make a form that will send a person's details to me in an email. I've been successful in getting the page to start a new email to the selected email address, but the input values from the form are not populating in the email. It's just empty.
Here is my code:
<form role="form" action="MAILTO: myemail#gmail.com">
<input type="text" placeholder="Name" id="name">
<br><br>
<input type="text" placeholder="Phone" id="phone">
<br><br>
<input type="email" placeholder="Email" id="email">
<br><br>
<button type="submit">Submit</button>
</form>
I've googled this and asked for help on the forums for the program I'm using to learn, but no success. Any help appreciated. Thanks!
Your code is right, but you were missing 2 things. 1 the method of the form, in this case method="post" and the inputs need a name not an id. Code is corrected below:
<form role="form" action="MAILTO: myemail#gmail.com" method="post" enctype="text/plain">
<input type="text" placeholder="Name" name="name">
<br><br>
<input type="text" placeholder="Phone" name="phone">
<br><br>
<input type="email" placeholder="Email" name="email">
<br><br>
<button type="submit">Submit</button>
</form>
Also to make the email better formatted I have added an enctype.

Creating a Google search box using HTML form

So I am trying to insert a search form on my website that will redirect the user with their query to Google Search.
I used to be able to do this using:
<form role="search" method="get" id="searchform" class="searchform" action="http://www.google.co.uk/search?hl=en-GB&source=hp&q=">
<div id="gform">
<label class="screen-reader-text" for="s"></label>
<input type="text" value="" name="s" id="s">
<input type="submit" class="btn fa-input" value="" style="font-family: FontAwesome;">
</div>
</form>
However, this no longer works. I'm guessing this is because Google have changed the search URL, but I am unable to replicate this effect by using Google's current URL.
Any idea how to fix this?
Hi all it seems I have solved the problem myself
<div id="gform">
<label class="screen-reader-text" for="s"></label>
<input type="text" value="" name="q" id="s">
<input type="submit" class="btn fa-input" value="" style="font-family: FontAwesome;">
</div>
The key here that resolved my issue is name="q". This is what you need to make google search work; basically this is because google expects q as the name
This snippet creates a simple google search box
<form action="http://www.google.com/search" method="get">
<input type="text" name="q"/>
<input type="submit" value="search" />
</form>

How to make an Image file to be automatically downloadable when an html form is submitted?

How to do make a file downloadable when the html form is submitted?
<form id="form" name="form" action="" method="">
<div>
<input type="text" name="name" id="name" value="">
</div>
<div>
<input type="email" name="email" id="email" value="">
</div>
<div>
<input type="text" name="dob" id="dob" value="">
</div>
<div>
<input type="text" name="phone" id="phone" value="">
</div>
<input type="submit" value="Submit"/>
</form>
You have two approaches:
From your server side, return a direct link to your file placed on the server (e.g: this image). Be careful with this option.
You load and process the image on your server, wrap and send it on the response via HTTP. (very useful if you have to send a pre-processed file like an auto generated PDF or XLS)
Both options have a lot of information and examples around the internet, just google it.

form action parameter not working

Test
<br><br>
<form action="index.php?page=test">
<input type="text" placeholder="enter text"> </input>
<button type="submit">Send</button>
</form>
Why is the link working correctly while the form gets me the url http://example.com/index.php? in the adress bar of the browser?
Every parameter i define in the action attribute is getting cut off
you have to use this code.
Test
<br><br>
<form action="index.php" method="get">
<input type="text" placeholder="enter text"> </input>
<input type="hidden" name="page" value="test">
<button type="submit">Send</button>
</form>
You are submitting a GET form. The data in the form will be expressed as a query string and replace the one in the URL in the action.
Move the data from the query string into hidden inputs inside the form.

Two submit buttons

I have two forms on a same page and I have two submit buttons...so how do I check if the user filled out the first form before clicking the submit button on second form? The first form posts the data to php page which presents on a same page as the html and the second form sends the data to another PHP page with thank you message....I mean how do force the user to finish the first form before clicking the submit button on the second form? if the user hits the submit button on the second form, the form directs to thank you page with out checking if the user finished the first form..how do I stop that?
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="submited" value="true" />
<label for="file">Choose Photo:</label>
<input type="file" name="file" onchange="file_selected = true;" required>
<input type="submit" value="Submit" name="submit">
</form>
<form action="Send.php" method="post">
First Name:<input type="text" name="fname" required><br>
Last Name:<input type="text" name="lname" required><br>
Choose Username:<input type="text" name="username" required><br>
Age:<input type="text" name="age" required><br>
<input type="submit" value="Submit" name="submit">
</form>
You can change the name field and then access the value on the server side.
For example:
<input type="submit" value="Submit" name="submitOne" />
If you're using php you could use something like this:
if(isset($_POST['submitOne'])){ /* first one pressed */ }
There are also some other options like using jQuery or javascript to validate first.
Try: http://bassistance.de/jquery-plugins/jquery-plugin-validation/