I've loaded various thoughts I've collected into mysql. I want to write an
app, all in one file, that has the following features:
1. On initial entry, selects and displays the thoughts ( might add
pagination later - there aren't alot of records, for now.)
2. This main page includes separate forms near the top with submit buttons
to search, add a thought, view all thoughts, etc. The action for each form
is to call this same page. The submit buttons and thoughts are printed from
a function.
3. In the main logic, I am trying to do a $_POST and if isset() on each
submit button name and then call a corresponding function, do whatever it
has to do, unset the form variable and continue back to the main display.
The problem is that it's not calling any functions. The error log says that
the name of each submit button in my $_POST[] statements in the main logic
is an undefined index. I presume that they are undefined in the main logic
because the forms were defined in a function.
Is there anyway to access, in the same page, form variables that were
declared in a function on that page?
Thanks! 1 7527
On 26-Oct-2003, "Jenkins" <ne**@djenkins. nu> wrote: I've loaded various thoughts I've collected into mysql. I want to write an app, all in one file, that has the following features:
1. On initial entry, selects and displays the thoughts ( might add pagination later - there aren't alot of records, for now.) 2. This main page includes separate forms near the top with submit buttons to search, add a thought, view all thoughts, etc. The action for each form is to call this same page. The submit buttons and thoughts are printed from a function. 3. In the main logic, I am trying to do a $_POST and if isset() on each submit button name and then call a corresponding function, do whatever it has to do, unset the form variable and continue back to the main display.
The problem is that it's not calling any functions. The error log says that the name of each submit button in my $_POST[] statements in the main logic is an undefined index. I presume that they are undefined in the main logic because the forms were defined in a function.
Is there anyway to access, in the same page, form variables that were declared in a function on that page?
Barring typos I think this illustrates what you want to do:
myscript.php:
<?php
if (isset($_POST['submit'))
{
$whichbutton = $_POST['submit'];
$somefieldvalue = $_POST['somefield'];
if ($whichbutton == 'Red')
// do red things
if ($whichbutton == 'Blue')
// do blue things
}
else
{
$whichbutton = 'None';
$somefieldvalue = 'Starting value';
}
?>
<HTML> ....
<p>The last button pushed was <? echo $whichbutton; ?></p>
<form action="myscrip t.php" method=post>
<input type=text name=somefield value="<? echo $somefieldvalue ; ?>">
....
<input type=submit name=submit value="Red">
<input type=submit name=submit value="Blue">
</form>
....
--
Tom Thackrey www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dSchwartz |
last post by:
This may not be a big deal, but I'm just kinda curious. If I have a
page that submits a form to itself, when is it better to assign each
element in $_POST to a variable to use for the rest of the page?
My situation probably doesn't make a difference, but say I have about
10 form fields, and when the page is posted back to itself, i call
each of those form fields 2 times (1 for error checking, 1 for SQL
insert, or to pre-fill form).
...
|
by: edward hage |
last post by:
Hello, I am new to PHP and I have the following problem.
In one php page I define some variables $teller, $budget. Also I ask for
some input from the user:
<FORM ACTION="resultaat.php" METHOD=POST>
<INPUT TYPE="Text" NAME="gemaakt" MAXLENGTH=3 SIZE=4 VALUE="0">
<INPUT TYPE="Text" NAME="verwacht" MAXLENGTH=3 SIZE=4 VALUE="0">
etc.
|
by: Joshua Beall |
last post by:
Hi All,
I cannot turn off magic quotes, since I am just leasing space from a hosting
company, and they determine the magic_quotes settings. I realize in
retrospect that using a .htaccess file to turn magic quotes would probably
be better, and I am going to switch to that solution, but I am still trying
to figure out what is causing my current problem:
I am using the following code to automatically strip out any slashes that
were...
|
by: Dan |
last post by:
I was trying to troubleshoot a login page that doesn't work - it keeps
saying the login/password is missing - when my tracing discovered this
peculiar behavior.
register_globals is off, so at the top of my script I assign a few
variables to incoming GET and POST values.
$login = clean($_POST, 30);
$passwd = clean($_POST, 30);
|
by: Jason |
last post by:
hello,
i am new to PHP, so go easy.
I am using the examples in the book:
PHP: Your Visual Blueprint For Creating Open Source, Server Side Content
In the section where they talk about getting values from a form
submission, the book says:
| |
by: Chris |
last post by:
I have a form that has the ID values of various fields from listboxes, etc.,
which are generated from a db query, assigned to variables. The variables
hold the returned $_POST fine, but I also need variables to
hold the labels. I have tried a few options such as running a secondary
query where the selected form value = the label, i.e.
-sample code-
//set variables:
|
by: Todd Michels |
last post by:
Hi all,
I am trying to send data from a form and insert it into a MSSQL DB.
When I submit the data I get: Warning: mssql_query()
: message: The name "Todd" is not permitted in
this context. Valid expressions are constants, constant expressions, and
(in some contexts) variables. Column names are not permitted. (severity
15) in "Myfile"
|
by: amygdala |
last post by:
Hi all,
I'm starting this new project in which I'ld like to implement sort of a
design pattern I have seen being used in the CodeIgniter framework.
Basically, the site will examine the URI and based on the segments of the
URI it will fire up some controller class, for instance, say I have an inbox
in which end-users can view messages they got from other users, they'ld
start at:
|
by: william.hooper |
last post by:
If I have a form:
<FORM ACTION="test.php"><INPUT TYPE=SUBMIT NAME="hello"
VALUE="Delete"</FORM>
then in test.php I could write:
$value = $_POST;
to set $value="Delete".
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |