html form is being sent on reset button - php

I have a problem with the html form.
This is my code:
<form name="contactform" method="post" action="send_form_email.php">
<input id="first_name" type="text" name="first_name" size="30"/>
<input id="company_name" type="text" name="company_name" size="30"/>
<input id="email" type="text" name="email" size="30"/>
<input type="image" align="middle" src="images/accept.png" alt="Submit" /> <input id="reset" type="image" src="images/reset.png" alt="Reset" align="middle" />
</form>
when I click any of this images my form is sent. How can I make this reset picture to only reset and not to send the form.

Your reset button is not a reset button. It has type="image", it is server side image map.
When you click on a server side image map the form will be submitted and the coordinates you clicked on will be included in the data.
If you want a reset button that is an image use:
<button type="reset"><img src="..." alt="..."></button>

The image type is like a submit button.
You have to take type="reset" and style your button with css.

Use
<input type = "reset" value = "" class = "btnResetClass" />
Your, btnResetClass will have Css Setting for background image to be set by you.

You have to use type="reset".
This jsFiddle example would be better.
HTML:
<form id="contactform" method="post" action="send_form_email.php">
<div>
<label>
First Name: <input id="first_name" name="first_name" type="text" size="30" />
</label>
</div>
<div>
<label>
Company Name: <input id="company_name" name="company_name" type="text" size="30" />
</label>
</div>
<div>
<label>
Email: <input id="email" type="text" name="email" size="30" />
</label>
</div>
<input id="submit" type="submit" value="" title="Submit" />
<input id="reset" type="reset" value="" title="Reset" />
</form>
CSS:
#submit, #reset {
border: none;
width: 64px;
height: 48px
}
#submit {
background: url('images/submit.png')
}
#reset {
background: url('images/reset.png')
}

Related

HTML Form Button

I want use my own button in form
When i'm using
<form method="post" action="check_login.php">
<input class="textbox" name="username" type="text" placeholder="Login">
<input class="textbox" name="password" type="password" placeholder="Password">
<div id="buttonPlace">
<p>Remember Me</p>
<input type="submit" value="Log in!" />
</form>
it works great. I would like to use my own button. When Im using this code :
<form method="post" action="check_login.php">
<input class="textbox" name="username" type="text" placeholder="Login">
<input class="textbox" name="password" type="password" placeholder="Password">
<div id="buttonPlace">
<p>Remember Me</p>
<div id="buttonLogin" type="submit">sing up</div>
</form>
Button doesn't work.
Why?
<form method="post" action="check_login.php">
<input class="textbox" name="username" type="text" placeholder="Login">
<input class="textbox" name="password" type="password" placeholder="Password">
<div id="buttonPlace">
<p>Remember Me</p>
<button id="buttonLogin" type="submit">Sign up</button>
</div>
</form>
Div can't have type="submit" property, only form inputs can have different input types property. If you want to style your submit button, use:
<input class="submitbutton" type="submit">Sign up</input>
and then define css style for your button class:
.submitButton {
.width: 60px;
.height: 20px;
.color: #dd5599;
}
If you want to submit form on click of your div, use need to assing its click a function to sumbit the form :-
$( document ).ready(function() {
$( "#buttonLogin" ).click(function() {
$( this ).closest("form").submit();
});
}
However, it is better to use button or input for submission.

How To Make .php form submit button two actions

Hello i want to make one form That Submits data to XXXXXXX and opens a new tab alongside with mydomain.com
Please Help Me To Get This..
<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;">
<label>
<input type="text" name="user" value="" style="width: 100%" placeholder="Your Code Here" autocomplete="off" autofocus="" required>
</label>
<input type="submit" style="width: 84px;margin-top: 10px;" value="Submit" class="submit">
</form>
Please Send me Some Details To Do This.. i Firstly Saw This on official-liker.net submit button..
Try this
<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;" target=_blank>
<label>
<input type="text" name="user" value="" style="width: 100%" placeholder="Your Code
Here" autocomplete="off" autofocus="" required>
</label>
<input type="submit" style="width: 84px;margin-top: 10px;" value="Submit"
class="submit">
</form>
The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.
For that you would need to use jQuery to submit the form using AJAX and in it's success callback via
window.open(url,'_blank');
Try something like below
<form action="XXXXXXXXXX.php" method="get" target="_blank" style="margin-top: 12px;">
If you want to get Redirected after the Post header("Location: http://www.example.com/") php function.
If you want to open alongside you can use JQuery.
<form>
<input name="text2" type="text" id="text" />
<a class="className" href="#" name="save" id="saveButton">Save</A>
</form>
After that some JavaScript stuff:
$(document).ready(function() {
$("#save").click(function(e) {
e.preventDefault();
$.post("sendPhp.php", { textPost : $("#text").val()},
function(html) {
//open a new window here
window.open("mydomain.com");
}
});
});
No need for Javascript, you just have to add a target="_blank" attribute in your form tag.
<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;" target=_blank>
<label>
<input type="text" name="user" value="" style="width: 100%" placeholder="Your Code Here" autocomplete="off" autofocus="" required>
</label>
<input type="submit" style="width: 84px;margin-top: 10px;" value="Submit" class="submit">
</form>
Following link will help:HTML form target

HTML PHP Contact Form - Submit Button Not Working? Or PHP Issue?

Hope you can help, I am trying to knock up a contact form for my website which is HTML, styled with CSS and the email sent with PHP.
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="button" value="Submit Form" />
</label>
</form>
Anyone help me out, can provide the link to my site if necessary.
Appreciate any help :)
You should use submit as the button type
<input id="button" type="submit" value="Submit Form" />
Fiddle DEMO
See updated FIDDLE
Have you tried changing:
<input id="button" type="button" value="Submit Form" />
to:
<input id="button" type="submit" value="Submit Form" />
Alternatively, you can use:
<button id="button" >Submit Form</button>
As you have it now, input type='button' is not a valid element for form submission. For valid form elements, MDN have a great article- see the sections input and buttons
Change type="button" to type="submit"
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="submit" value="Submit Form" />
</label>
</form>
In this particular case, I agree with the suggested solutions re: type="submit.
But I arrived here due to having my buttons stop working all of a sudden, though a Select submit was still working. And it was due to a tiny bug in some Javascript that was killing the submission.
Just something else to check.
try this html form
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="submit" value="Submit Form" />
</label> </form>

Auto populate form and auto submit with URL Parameters

I want to auto populate the below form with URL parameters for example using a URL like this:
example.co.uk/example.php?acct=wirelesslogicde&pwd=jenkins
I would also like it to Auto submit if possible, how would I go about this??
<form action="http://www.twg.com/logincheck.aspx" method="post" name="login" style="margin-bottom: 0;">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" size="12" maxlength="16"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16"/><br /><br />
<input type="submit" name="submit" id="submit" class="button" value="Login"/>
</p>
</form>
NEW FORM:
<head>
<script src="jq.js" type="text/javascript"></script>
</head>
<form action="http://www.zstats.com/logincheck.aspx" method="post" name="login" style="margin-bottom: 0;" id="zstatslogin">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['acct']; ?>"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['pwd']; ?>"/><br /><br />
<input type="submit" name="submit" id="login" class="button" value="Login"/>
</p>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#login").submit();
});
</script>
<form action="http://www.twg.com/logincheck.aspx" method="post" id="login" name="login" style="margin-bottom: 0;">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" value="<?=$_GET['acct']?>" size="12" maxlength="16"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" value="<?=$_GET['pwd']?>" size="12" maxlength="16"/><br /><br />
<input type="submit" name="submit" id="submit" class="button" value="Login"/>
</p>
</form>
Use $_GET to get the values from URL.
For auto submit use, Make sure you have jquery plugin loaded before you use the following script. If you don't have JQuery added get it from JQuery and include the file like any other javascript file in your <head> section of HTML document.
$(document).ready(function() {
$("#login").submit();
});
you could do the autosubmit by using jQuery
$('#some_form_id').onLoad(function(){
$.Post('form_target',{parameters:values});
});
and for the populate you can add
<input name="acct" id="acct" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['acc']; ?>"/>
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['pwd']; ?>"/>
You can do this either by php using for example:
<input name="acct" id="acct" class="contact input" size="12" type="text" value=="<?php echo $_GET['acct'];?>" maxlength="16"/>
or using javascript, which would be a bit more complex, look at the window.location.search to filter down querystrings..
ref: https://developer.mozilla.org/en-US/docs/DOM/window.location

Not calling Post Data

Im having trouble trying to call POST data on my page,
My form is...
<form method="post" enctype="multipart/form-data" action="getdata.php">
<input type="hidden" id="TimeToRenderHoursInput" name="TimeToRenderHoursInput" value="" />
<input type="hidden" id="TimeToRenderDaysInput" name="TimeToRenderDaysInput" value="" />
<input type="hidden" id="TimeToRenderYearsInput" name="TimeToRenderYearsInput" value="" />
<input type="hidden" id="ContentMinutesInput" name="ContentMinutesInput" value="" />
<input type="hidden" id="ContentMinutesSelector" name="ContentMinutesSelector" value="" />
<input type="hidden" id="PriorityInput" name="PriorityInput" value="" />
<input type="hidden" id="AvgFrameRenderTimeInput" name="AvgFrameRenderTimeInput" value="" />
<input type="hidden" id="AvgFrameRenderTimeSelector" name="AvgFrameRenderTimeSelector" value="" />
<input type="hidden" id="CoresInTestInput" name="CoresInTestInput" value="" />
<input type="hidden" id="EstPriceInput" name="EstPriceInput" value="" />
<input type="image" src="images/CONTINUE.jpg" style=" border:none; padding:0; width:206px; height:41px; float:right; display:none;" id="continue" />
</form>
and my php page which should get the data is
<?php
$quantity = $_POST['TimeToRenderHoursInput'];
echo $quantity;
?>
The values in my form are populated before its sent using Javascript...
Just remove "display: none" from:
<input type=image ... >
and it will work.
The accepted answer above works too, of course. Just thought I'd point out where you went wrong in your code.
write before closing the <form>
<input type="submit" name="submit" value="Postdata" >
or wrap you image with submit button
<button type="submit" name="postdata" id="postData">
<img src="images/CONTINUE.jpg" style=" border:none; padding:0; width:206px; height:41px; float:right; display:none;" alt="Continue" title="Continue"/>
</button>
and also debug by writing below on getdata.php
echo "<pre>";
print_r($_POST);
echo "</pre>";
one more thing : Just remove display: none from <input type=image ... > ( Thanks #johndodo)
Note: if you use image to submit a form then get the data using image name dimension like this ( $_POST['submit_x'] OR $_POST['submit_y'] )
<form >
<input type="image" name="submit" src="whatever" value="Continue">
</form>
<?
if($_POST){
print_r($_POST);
}
if($_POST['submit_x'] || $_POST['submit_y']){
echo "An image button was used";
}

Categories