Jump to content

Form Loads the Script Itself


Glese

Recommended Posts

<!-- 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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.