Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-18-2005, 09:55 AM #1
- Join Date
- Jul 2005
- Thanked 0 Times in 0 Posts
Update DB using other than submit form
Perhaps my other question was too 'much' to start with.
So i'll break it down and ask the main question.
How do I submit to a DB with out using the 'submit' function in a form.
I think I need to do this as my code is being included from a functions page.
So i'm guessing the variable isn't being passed.
Also, the other issue is that once I do hit submit it reloads the index page rather the edit.php page. Obviously index.php is my default in the switch case.
// Set varibale for switch action
$action = isset($_GET['action']) ? $_GET['action'] : '';
case "addSAStockSummary" :
09-18-2005, 03:07 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,650 Times in 2,619 Posts
Databases by no means require the use of submit, that simply provides us with a way to create the variables, perhaps one of the easiest to use and control.
You can update the database through the standard UPDATE query (OR INSERT if not existant), and your variables can be hardcoded, passed through post/get, etc.
Now, I'm not certain on your problem exactly, but if its relative to using POST then the issue lies in your _GET. Change it to _REQUEST instead, that will cover either the POST or GET, where POST overrides GET. That will allow you to use this either with a POST form, or through the url.
Functions can be generally tricky as well, you have to be careful of your scope. Functions can only see two things -> themselves and superglobals. They cannot see anything else by default. Any variables that need to be include which are not relatives of the superglobals need to be added with a global $var command. This scope is something that traps a lot of people, especially new people. This is also the reason why I always comment on using _* vars instead of HTTP_*_VARS, as HTTP_*_VARS are not autoglobal and need to be globalized within a function use. I myself initialize the HTTP_*_VARS as a part of the superglobals for olderversions of php, and therefore need to globalize these variables for use with older versions within the array:
global $_POST for instance. Normally $_POST is global, but it may not be with the older versions as my code.
And lastly, the switch() function does not require that your default case be broken. Actually, its not the default, its the last case of switch doesn't need a break in it. I don't *think* this causes problems, but I'm not certain -> I've never used a break with my last case
Is this of any help to you?PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');