I have a web site with several php pages, one of them (called form.php for instance) prints with echo a form which action is sending the form itself with action=$_POST[PHP_SELF], the problem I have is due to security my web site is an Index.php page with another page include,another one and another one which is form.php.
When I click "submit" on the form the "submit" goes to Index, not to form.php, how can I solve that ? If I use the if(isset($_POST['submit'])) in the index works fine but with different results, I want this to work in the form.php page, let's say I just want to run a function, add data to mysql and show a sentence saying done, I do everything, but going through index.php and including the form.php again.
Any help ? thanks in advanced.
Related
I'm having a problem trying to submit the form automatically using php-webdriver client, everything went fine until one day my script was no longer able to submit the form. The process of filling form is really simple:
I have my fields that I want to populate in that form and click submit button with attribute name="submit". Everything worked fine but now the same code somehow doesn't cut it.
$input = $this->driver->findElement(WebDriverBy::name('first_name'));
$input->sendKeys('Example');
$submit = $this->driver->findElement(WebDriverBy::name('submit'));
$submit->click();
This is pretty much what my script does it finds a few fields and sends some values after that I simply click the submit button. After the submission, I checked what response I get using getPageSource() method, and surprisingly it showed me different page, but in the right circumstances it should be on the same page. If I delete every line of code that uses sendKeys() method then it stays on the same page which is the correct behavior. But I'm not understanding why sendKeys in combination with $submit->click() causes something like 'redirect' it redirects to index page which is initial website page and it used to work correctly, I checked everything many times and it looks that I provide all required fields correctly and able to submit the form. But instead of successful form submission response, I see that I'm on the index page.
Maybe there are known issues with this but I'm just not aware of it? Some advice, ways of how could I debug it would be really helpful because now I'm clueless, there's simply no indication of what went wrong.
I'm wondering the best way to go to a new page. I have a PHP document with a submit button. Once that button is pressed, it runs the php code on that page, creates some session variables, then I want it to go to the next page after this code is executed. I know with traditional submit buttons you simply have the form that's run being the next page, but how do I link it differently?
You can force redirect with successful headers like as below:
header("Location: second.php");
In a well designed web application, there is no direct relation between the script and the page as the control script is the same for every page and simply shows the page needed based on what was selected or done.
There are many ways to implement this but a good starting point would be to look at MVC design.
set the URL of new page on form action='' to load the another script after submit the form.
I have created a single page portfolio template using Bootstrap framework from Twitter. I am having an issue that when I click on "Submit" button in the contact form, the page scrolls all the way to top. I have checked that I have not used any internal linking to top so I am not sure why this happening. My intention is to stay on the same page and show user some friendly message. Can anyone help me figure out the issue? Thanks in advance!
Template can be accessed at:
https://rawgit.com/gupta235/portfolio_template_bootstrap/master/index.html
I have made the template available on my github page: https://github.com/gupta235/portfolio_template_bootstrap
Forms typically send you to a new page. Since your form is all in one page, the "new page" its sending you to is the same one you were already on, and so it sends you to the first part of that page, which is the top.
You can prevent the page from scrolling to the top by giving the form an action ability that instead of sending you to a new page or the top of the current page, will take you to an id that you place somewhere on the page.
Same concept as putting an anchor point on your page and giving people an option to click a link that takes them to a certain part of the page.
For example if you change your form opening code from
<form method="post">
to this instead
<form method="post" action="#error-check" id="error-check">
This should take you to the form when you hit submit, instead of the top of the page.
A form without an action attribute is not a form, according to standards - and will actually cause a page reload in some browsers.. I've found that action="javascript:void(0);" works well.
I've been looking ofr a while but I'ven't found any question that solves my question:
I've a php page with some forms, it's a long page and users may use one or some of the forms each time they connect to the website. When an users submits one of the forms the forms calls the same page but with the data updated (that works good for me).
The problem is that I would like that after submiting any form, the new page starts in middle of the scroll where the form submited is, so the user hasn't to go to the start of the page.
I'm not sure if this can be done with php or I need javascript (i don't know anything about javascript yet).
Use an id to navigate between elements in a page. Put # in action attribute when the user submits the form the browser will navigate to the form location
Example
<form id="example" action="yourpage.php#example" method=...>
<form id="example2" action="yourpage.php#example2" method=...>
So I changed the structure of my site around some and such and I guess I broke the script some how.
When the user fills out a form correctly, they should be directed to the appropriate page. Instead it just sits there. However, if I test the form directly from form.php it works.
Here is some info on the form.
form.php is the actual form. submit.php does error checking, inserting into database, email message, redirect. script.js does ajax to make the form more user friendly.
Remember, this all works if I go directly to form.php and fill out the form. However, going to register.php which simply has added to it the header and footer and the body for form.php it does not work. What could be wrong?
Thanks for your time.
You propably included the jQuery framework twice, that causes much problems.