I have a html form which posts to a php script. It works fine in chrome and firefox but not in IE. I have ran a test on W3C but can not find any errors that relate to the form. My code is:
<form class="formular" id="formular" method="post" action="script/contact.php">
<fieldset>
<label>
<span>Name : </span>
<input type="text" class="validate['required','length[3,-1]','nodigit'] text-input" name="Name" />
</label>
<label>
<span>Email address : </span>
<input type="text" class="validate['required','email'] text-input" name="email" />
</label>
</fieldset>
<div class="button">
<input type="submit" value="Contact" class="submit" />
</div>
</form>
Thanks in advance
Form is correct. Looks like wrong handling form on server side. how you catch result?
Related
Using HTML form with action = "www.google.com", but it redirect to link including localhost/www.google.com . My example code is for your reference. Please anyone help me.
My Forms as follows :
<form method="POST" action="www.google.com">
<p>
<label for="name">Name:</label>
<input type="text" name="name" id="name">
</p>
<p>
<label for="email">Email:</label>
<input type="email" name="email" id="email">
</p>
<p>
<label for="comments">Comments:</label>
<textarea name="comments" id="comments"></textarea>
</p>
<p>
<input type="submit" name="send" id="send" value="Send Comments">
</p>
</form>
But, the file when click send button, it redirects to
" http://localhost/basic/www.google.com" error page. Can any one suggest me to resolve the issue.
It is not allowed to send POST request directly to google.com. Why do you want to do this? In the action argument you should have own script which can process request from your form.
Replace your form action
From
action="www.google.com"
To actual link
action="https://www.google.com"
I have been trying to pre-fill the subject input with information generated in another page, but have been having difficulties with it despite reading a lot of resources about it and seeing examples. I have tried a variety of links, including my most recent attempt with http://www.myurl.com/folder/index.php/contactform?subject=test, but even that doesn't work. Anybody have any advice? Also, if you want to test it out before answering, the page experiencing the problem is the contact page of this website. I've removed information from below to make it more general. Thanks in advance for any and all of the help.
<form id="contactform" method="post">
<input name="recipient" type="hidden" value="myemail" />
<input name="subject" type="hidden" value="Contacter" />
<p id="contactname">
<label>Name:</label>
<input name="name" type="text" />
</p>
<p id="contactemail">
<label>Email:</label>
<input name="email" type="text" />
</p>
<p id="title">
<label>Subject:</label>
<input name="title" type="text" />
</p>
<p id="contactmessage">
<label>Message:</label>
<textarea name="message"></textarea>
</p>
<p id="submit">
<input type="button" value="Send" />
</p>
<input name="redirect" type="hidden" value="myredirectpage" />
</form>
Lets say your page URL is some thing like below
http://www.example.net/index.php?var1=Something&var2=10&var3=ok
You can use $_GET to get the values of var1, var2,and var3 from the above url
In index.php use the below code to fetch url data
echo $_GET['var1'] // Something
echo $_GET['var2'] // 10
echo $_GET['var3'] // ok
Go through this link http://php.net/manual/en/reserved.variables.get.php
With php you can do this with a session.
On the other page(not the form) you can do $_SESSION['subject'] = 'your subject';
On the form page you can acces this cookie ( make sure you have started the session on top of the page with session_start():
<p id="title">
<label>Subject:</label>
<input name="title" type="text" value="<?= $_SESSION['subject'] ?>"/>
</p>
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>
I wonder whether someone could help me please.
I'm put together the following form contained within a PHP file.
<form name="savemyfindstolocation" id="savemyfindstolocation" method="post">
<p><label></label>
</p>
<p align="left">
<input name="userid" type="text" id="userid"/>
<input name="locationid" type="text" id="locationid"/>
<br />
</p>
<div>
<label>
<div align="left">Click on the map to place the marker for the find that has been made and drag until the precise location has been found. </div>
</div>
<p align="left"><label>Find OSGB36 Latitude Co-ordinate<br />
</label>
</p>
<div>
<div align="left">
<input name="findosgb36lat" type="text" id="findosgb36lat" size="20" />
</div>
</div>
<p align="left"><label>Find OSGB36 Longitude Co-ordinate<br />
</label>
</p>
<div>
<div align="left">
<input name="findosgb36lon" type="text" id="findosgb36lon" size="20" />
</div>
</div>
<p align="left"><label>Date of Trip<br />
</label>
</p>
<div>
<div align="left">
<input name="dateoftrip" type="text" id="dateoftrip" size="10" />
</div>
</div>
<input name="submit" type="submit" onclick="MM_callJS('savedata()')" value="Submit" />
</form>
It all works fine, but I'd now like to add a button that opens the following php page, 'blobupload.php'. If I've understood this correctly from the research that I've done, I need to use javascript to open the page, using the 'submit' action from the main form.
What I don't understand is how to do this when the 'submit' action is already taken for the saving of the information on the main form.
Could someone perhaps please show me how to get around this, i.e. using the same 'submit action but for two different purposes.
Just modify your form tag (add the action attribute to file you want to load):
<form name="savemyfindstolocation" id="savemyfindstolocation" method="post" action="blobupload.php">
And you submit input tag:
<input name="submit" type="submit" value="Submit" />
You can use a second javascript function to open new window like this way
<input name="submit" type="submit" onclick="MM_callJS('savedata()');SECOND_JS_FUNCTION()" value="Submit" />
Use php to process the form is one of the way to do it.
<input name="submit" !!!!!!action="process.php" method="POST (or get)!!!!!!!!!! type="submit" onclick="MM_callJS('savedata()')" value="Submit" />
that way the the variable will be passed to the process.php while you can also redirect the page in the process.php
header("Location:URL");
I hope someone can help me. I'm a little at loss on how I can achive this: I'm trying to pass infos generated in my php to another form made in Javascript. For example, if I put my first name in the input field and click submit, then it would go to another page with the actual form and have the first name already filled there.
One thing that I did notice was that the javascript form isn't within the <form> tag, it's in a bunch of tables with some input fields. I can post what it looks like in pastebin if this can help in understanding what I mean.
Also with this script im unable to edit it, I did not make it, it is one of those script you just place on your site thats auto generated.
My form looks like this:
<form action="auto-form/index.php" method="post" name="openleads" onsubmit="return checkForm(this);">
<label for="first">First Name <span class="required">*</span></label>
<input id="first_name" type="text" name="first" applicationforms="true" /><br>
<label class="error" for="name" id="first_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Zip <span class="required">*</span></span>
<input id="zip" type="text" name="zip" applicationforms="true" /><br>
<label class="error" for="name" id="zip_error" style="color:#F00; font-size:11px;">This field is required.</label>
<label for="last">Last Name <span class="required">*</span></label>
<input id="last_name" type="text" name="last" applicationforms="true" /><br>
<label class="error" for="name" id="last_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Email <span class="required">*</span></span>
<input id="email" type="text" name="email" applicationforms="true" /><br>
<label class="error" for="name" id="email_error" style="color:#F00; font-size:11px;">This field is required.</label>
<input class="button" type="submit" name="send" value="Send" />
</form>
Any help is appreciated; like I said, I'm a bit at loss on what to do with this one.
php-form.php
<form action="javascript-form.php" method="post">
<input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
javascript-form.php
<form action="" method="">
<input type="text" name="name" value="<?= (isset($_POST['name'])?htmlentities($_POST['name'],ENT_QUOTES):''); ?>" />
<input type="submit" value="Submit" />
</form>
Use PHP to output the POSTed values in to the value attribute of the form fields. You can also use GET variables and use javascript to parse the window.location and scrape those form values.
this seemed to get this done
<script type="text/javascript" src="http://jquery.offput.ca/js/jquery.timers.js"></script>
<script>
$(document).everyTime(1000,function(i){
if($('#ui-datepicker-div').length>0)
{
$('#first_name').val('<?php echo $_POST['first_name']; ?>');
$('#last_name').val('<?php echo $_POST['last']; ?>');
$('#zip').val('<?php echo $_POST['zip']; ?>');
$('#email').val('<?php echo $_POST['email']; ?>');
}
})
$('#first_name').val('test');
</script>