Glese Posted November 29, 2011 Share Posted November 29, 2011 <!-- The Input Form --> <form action="changemail_script.php" method="POST" > <input type="text" name="new_email" /> <input type="submit" name="submit_new_email" value="Submit" /> </form> When I have it as above, and I click submit, then the form loads the script itself and since the database connection variables are included into the header it will not work anymore. Any ideas why it does that? Should rather just include the script file and simply leave the action field empty, or do you have a better suggestion? Quote Link to comment Share on other sites More sharing options...
Spring Posted November 29, 2011 Share Posted November 29, 2011 I don't understand your question Quote Link to comment Share on other sites More sharing options...
Glese Posted November 29, 2011 Author Share Posted November 29, 2011 The form loads the script FILE in a new window. Quote Link to comment Share on other sites More sharing options...
trq Posted November 29, 2011 Share Posted November 29, 2011 This is normal functionality. I don't see the issue. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 29, 2011 Share Posted November 29, 2011 I don't understand what you are talking about either (we are not standing right next to you and don't know what you saw in front of you) and I have a significant amount of experience decoding what people state in their posts. Are you seeing the actual php source code of the changemail_script.php file? Quote Link to comment Share on other sites More sharing options...
Glese Posted November 29, 2011 Author Share Posted November 29, 2011 Normally, when I click submit, the script becomes executed in the background and I get a confirmation and that's it, if this was a normal issue I would surely not post a thread on it, kind of pointless to even assume otherwise. This time I click submit and the php script file itself gets loaded in a new page, I do not see the source code, but I do see a bunch of error messages. When I do include the script file into the form file and I leave the action attribute empty, then it does work, but as soon as I use the action attribute it does not work anymore. I am expecting the script to execute in the background while still keeping the form in my view and not opening the script file itself in a new page with a bunch of error messages. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted November 29, 2011 Share Posted November 29, 2011 Are you by any chance using jQuery or some sort of AJAX to submit your form? It's sounds like that to me. Regards, PaulRyan. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 29, 2011 Share Posted November 29, 2011 The reason we don't understand what you are stating is because some of the terminology you are using is a bit off, probably because your interpretation of what is happening between the browser and the web server is a bit off. When you request any page from the web server, the web server sends the requested page back to the browser, then the web server goes on to service other http requests. The web server is not sitting there waiting for you to submit a form and in fact other than a line in the server's access log file, there is no evidence that a page containing a form has ever been requested. There is no 'background' processing going on, just http requests to the web server and the response that the server sends back to the browser. When the processing on the server reaches the end of any page that was requested, all the resources used by that page are destroyed. Each http request is completely separate from every other http request. For any form (it does not matter what the action= attribute is) when the browser submits the form, it makes a http request for the URL supplied by the action= attribute and it submits the form data to that URL. For the case of an empty action="" attribute, that just means that the browser requests the same URL that the form is on. For the case of an absolute or a relative URL in the action attribute, the browser either uses that absolute URL directly or produces an absolute URL from the current page and the relative URL information. In your example where you have an empty action="" attribute, when you submit the form, the page in the browser actually completely changes to whatever your code outputs to the browser in response to that http request, but it sounds like the code on your page outputs the form again along with a status message. In your example where you have a different page as your action= attribute, it sounds like you don't have the complete code needed to process the form submission as part of that target page. Any php code that exists on your form page only exists on the form page. Quote Link to comment Share on other sites More sharing options...
trq Posted November 29, 2011 Share Posted November 29, 2011 Normally, when I click submit, the script becomes executed in the background and I get a confirmation and that's it, if this was a normal issue I would surely not post a thread on it, kind of pointless to even assume otherwise. There is no such thing as 'background processing' in http. You can make it look that way using Ajax, but you should really understand how the normal process works first. If your having trouble with the code within changemail_script.php why not post that code? You'll want to accompany that code with a better description of the problem than "I do see a bunch of error messages" though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.