I have a form like below on my index page:
<form action="send.php" method="POST">
<b>Your name :</b> <input type="text" name="name"><br>
<b>Your e-mail :</b> <input type="text" name="email"><br>
<b>Message</b><br><textarea name="message"></textarea>
<input type="submit" value="Send">
</form>
When I click the submit button, it posts the values on the index form still instead of navigating to send.php
/index.php?name=chris&email=heymega%40gmail.com&message=HELLO!
Notice how its still on the index page. Any ideas why this is happening?
Both files exist in the root directory.
Either you already have another form tag open that you haven't closed earlier on the page, or it's not liking that you have POST in uppercase - I believe it should be lowercase.
Ok really taking a shot in the dark here since you said that it isnt nested in anyother forms and that it "still" sends to index.php that you need to press ctrl+F5 to refresh the possibly cached version of this page.
If that doesn't work then post your complete html code with the javascript.
Related
I have a database with some numbers assigned to a fake account (PHP).
I try to contact the database (with success) and get the right result from the form.
My issue is that the form result open a new page and display there...
I would really like the result to be displayed IN the module I use to send the form OR anywhere else on the same page I used to send the form.
<!DOCTYPE html>
<html>
<body>
<form
method="post"
action="http://ggdbase.dx.am/impulseGetInfo.php"
target="_self">
Account name:<br>
<input type="text" name="name" value="derps">
<br>
<input type="submit" value="Click To Load Account Info">
</form>
</body>
</html>
This is what the module look like (on Enjin.com)
This is what I get when clicking the button
I did try replacing '_self' with '_blank' or parent and all the other options I could find but none of them gave me a different result :S
Could it be caused by the Enjin system itself ?
Do not use target. And replace the action as
action=""
This will ensure that you are calling the same page. Write the PHP code there itself.
Hope that help!
I'm looking to modify the pagination in Magento in an order to give user an opportunity to switch to any page at any moment. To my mind it can be a text field, when somebody enters page number x, it will redirect to http://www.domainname.com/catalogpage.html?p=x
Any ideas of this php line?
<form action="catalogpage.html" method="post">
<input type="text" name="p">
<input type="submit">
</form>
Works?
I'm a noobie programmer and I wonder how to properly submit a form with javascript.
I made some test code to show you what I mean:
<?php
if (isset($_POST['message']))
{
echo $_POST['message'];
}
?>
<script>
function formsubmit()
{
document.getElementById('form').submit();
}
</script>
<form id="form" name="form" action="" method="post">
<input id="message" name="message" value="hello world">
<input id="submit" name="submit" type="submit">
</form>
Click me<br/>
<input type="submit" onClick="formsubmit()" value="Click me">
When you push the "submit" button inside the tags - the php code will echo "hello world".
When submitting the form with JS the values won't post to the page. What am I doing wrong?
Thanks in advance.
I've searched the whole afternoon for a solution, but cause of my lack of knowledge about programming I failed to find it.
Believe it or not, but the main problem lies here:
<input id="submit" name="submit" type="submit">
If a form contains an input element with name (or id) of submit it will mask the .submit() method of the form element, because .submit will point to the button instead of the method. Just change it to this:
<input name="go" type="submit">
See also: Notes for form.submit()
The smaller problem is here:
Click me<br/>
An empty anchor will just request the same page again before calling formsubmit(). Just add href="#".
The problem here is that the id and name of the input element on your form is called submit.
This will mask the submit function for the form. Change the name and id and you will be able to use javascript to submit the form.
try setting the href of the to '#'. I would guess what is happening is that by clicking on the link, it submits the form and immediately changes the url to the same page you are on cancelling the form submit before it has a chance to go.
I searched all day for the right answer on stackoverflow, also I couldn't find something helping me out.
Having a simple form like this:
<form action="process.php" method="post">
<input type="text" name="email">
<input type="password" name="password" id="password">
<button value="Login" type="submit" name="submit" onclick="formhash(this.form, this.form.password);"></button>
</form>
currently: Submitting the form redirects to process.php showing a success message & redirecting to another page after some time.
What I need: instead of redirecting to process.php a modal dialog box should open doing the work and showing a success message, closing the dialog box after some time and then doing a refresh of the actual side.
Any help is welcome!
Use ajax submit, JQuery already supports this. Try JQuery API http://api.jquery.com/ especially http://api.jquery.com/category/ajax/ Examples are provided on that site too.
This might be what you are looking for:
Message Box opens then disappears
There is also a similar question here on stackoverflow: Link
I have a main.php page
the following code is hardcoded in main form
<form action="test.php" method="POST">
the following is the code generated dynamically using AJAX
<input type="checkbox" value="test" name="test[]"/>
<input type="checkbox" value="test1" name="test[]"/>
<input type="submit" value="go">
ideally speaking on clicking the go button the page should submit to test.php page with the post value of the check elements
but now i find no action is taken by the browser. Also i find no error message in error console.
this used to work upto firefox 3.5 and IE 8. However in Firefox 3.6 the dynamically generated form elements are not recognized at all
Is there a mistake in the code and is a there a work around
Make sure that the dynamic content does not replace the form .. but gets appended to it (or replaces the contents and not the actual form tag..)