I'm programming a webpage and in my index, I have two forms.
The 1st is for the login:
<form method="post" action="login.php">...</form>
The 2nd is for search:
<form method="post" action="search.php">...</form>
My problem is that when I submit the search form, it works as if the action is targeting login.php. When I see the source code, the tag <form method="post" action="search.php"> doesn't appear.
The most probable cause of the problem is incorrectly nested forms or missing closing form for login form. Check the generated HTML for the validity of the HTML and if not post the generated HTML so that we can help you debug.
It is hard to tell without seeing the complete page, but I would guess that you have one form inside the other — which is forbidden. You cannot nest forms.
Turns out I didn't really close the form tags, I typed <form> instead of </form>. Sorry.
Related
I am submitting an HTML form to the same page to handle with PHP and figured out that I can use action="./", which works fine for me so far (in a test environment).
I am a little unsure though because all the examples I find recommend using either
action=""
or
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
I don't want to use action="" because the HTML Standard specifically states
The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.
Is there any reason not to use action="./"? It seems better (more readable, less PHP) to me but it's confusing me that all the examples I find recommend the PHP approach.
Using ./ works in a lot of cases but can lead to unwanted behaviour if not understood correctly. It's also unnecessary as default behaviour of forms without the action attribute is to submit the form to the same page.
Use <form method="post"> to submit to the same page.
Don't use <form action="" method="post">. This will also submit to the same page but it's invalid according to the HTML standard.
Everything works well behind the scene but my clients see a Page not found after Posting a form.
The form.php must have been found otherwise the data wouldn't be parsed to my e-mail smoothly. I have a redirection page: thankpage.html, which is up and running well when I type its address directly.
what could be going on? any help please?
Anyway,
Instead of calling the Thankpage.html from the form.php, I inserted the following into my "form" element in the contact.html page itself:
onsubmit="window.location.href='http://www.inglesparticular-sp.com/thankpage.html';"
So it is now:
<form role="form" id="contact-form" method="post" action="form.php" onsubmit="window.location.href='http://www.inglesparticular-sp.com/thankpage.html';">
Somehow it's all working well and I have no "PAGE NOT FOUND" messages!!!
Sorry if I wasn't clear on the question, it's my first one as you can see... cheers!
So I have a profile page: profile.php?pin=xx, where I use the GET method for determining which profile to display. I am going to test if $_SESSION['pin'] == $_GET['pin'] and if so, give the option to edit profile.
I don't want to write a-whole-nother script and direct the user to another page. So for usability sake, and keeping the server neat so I'm not always guessing which script does what, I want to mix POST and GET. I've done some research and it seems legal, but how?
<form method="post" action="profile.php?pin=xx">
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
That's all I can think of without really getting the code messy.
If you keep the action attribute empty it will be the same URI including the GET parameters (query-info part of the URI):
<form method="post" action="">
Maybe this is what you're looking for? See HTML <form> tag for a reference about tag and attribute.
If you want to understand how that works: This is a so called Relative URI. It resolves to the Base URI of the document. As the Relative URI is empty, the Base URI is being taken over completely.
I would like to use the data entered in the html form and insert into MYSQL. I have a separate php (cus.php). but nothing is happening with current code I have
at the moment when I click "register" I'm nav to the php file. Thank you
You forgot the most important thing about an HTML form: the <form> tag.
You have to wrap the whole form (all inputs) which should be submitted when clicking like this:
<form method="POST" action="cus.php">
...
</form>
This will send all inputs to cus.php and make them available there as variables $_POST['input_name']. You can alternatively use GET as the method (and then use the $_GET array instead).
Edit: Didn't see it, you actually do have a form tag. However it's missing the target file in its action attribute.
First, see DCoder's comment. It's the most important.
Change:
<form action="" method="seller">
To:
<form action="cus.php" method="post">
Does that fix it?
Try to do this
FORM action="your script" method="Post"
I have a structure like :
<form id="first_form">
<fieldset>something</fieldset>
<fieldset>
<iframe><html> ...
<form id="second_form">
<input type="hidden" value="**some_value**" name="hidden_data" />
</form>
</html></iframe>
</fieldset>
</form>
What i need from this structure is to take the value from "hidden_data" in main form, and then to go post in database. I tried to prin_t($_POST); die; (after submitting first form) but i don't receive any input from second_form. Does somebody have an idea? Regards
Note : It's about wordpress plugin tdo mini forms
Note 2 : I want to get an url from an uploaded file (url which i get after i submit second_form) and then add as post meta, using first_form.
You can't just dump HTML inside of an iframe element. Any children of iframe are simply there to be displayed if the browser can't handle iframes.
Also, nested form elements doesn't validate (in HTML 4.01 Strict anyway, and I doubt in any others).
Why are you using an iframe with a form in it? Seems strange. And having HTML inside of that isn't what it is <iframe> tag is used for. Would be best to just have 1 form id="first_form" with the hidden element from the form id="second_form" in it. You can't put a form inside of another form, there can only be one at any given time.