473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with <SELECT post > and $_POST()

I am cross posting to comp.lang.php and alt.comp.lang.p hp.

I am having a problem with getting a post from a dropdownlist off a html
form. While debugging, by instruction steps, for some reason I am never
get passed the isset($_POST['author_pk']) after selecting an item in the
dropdownlist.

I have coded a simple script to duplicate what I am trying to do, just
to make sure i understand it, and that works. This is the code and has
to be something simple..

<?php
//
// Debugging
$debug = false;

//
// Open DB
include 'library/opendb.php';

// This form uses the POST method, so process any post selections here
if( isset($_POST['author_pk']) ) {
echo 'Ok I have an author Primary Key';
// do whatever you need to do with the author_pk
// $sqlcmd = $author_detail_ select . {$_POST['author_pk']};
// $author_detail = mysql_query($sq lcmd);
}
//
// main form query
if ($debug){
$sqlcmd = $author_dropdow n_select . ' ' . limit();
echo $sqlcmd;
} else {
$sqlcmd = $author_dropdow n_select;
}
$result = mysql_query($sq lcmd);
if (!$result) {
die('Database Error: ' . mysql_error());
exit;
}
//
// Close DB
include 'library/closedb.php';
?>
/*
Can't use 'PHP_SELF' under PHP Designer. Works running off server.
<FORM NAME="author" method="post" action="<?php echo
$_SERVER['PHP_SELF'];?>">
*/
<FORM NAME="author" method="post" action="PeopleQ uotes.php">
<SELECT NAME="author_pk " SIZE="20" COLS="20">

<?php
// a loop to populate the select options
while( $row = mysql_fetch_obj ect($result) ) {
printf("<option value=\"%d\">%s %s, %s %s %s</option>\n",
$row->id, $row->TITLE, $row->lastname,
$row->firstname, $row->middlename, $row->SUFFIX);
}

mysql_free_resu lt($result);

// display any author details based on the user's selection
if( isset($author_d etail) ) {
// while( $row = mysql_fetch_ass oc($author_deta il) ) {
// printf("Title: %s<br>\n", $row['title']);
}
}
?>
</SELECT>
</FORM>

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Jul 14 '06 #1
5 2547
I have coded a simple script to duplicate what I am trying to do, just
to make sure i understand it, and that works. This is the code and has
to be something simple..
Maybe a stupid question, but how do you submit your choice? I don't see
a submit button in your form and neither a javascript call to submit the
form automatically after selecting an item from the picklist.

Peter.
--
http://www.phpforums.nl
Jul 14 '06 #2
Rik
IchBin wrote:
I am cross posting to comp.lang.php and alt.comp.lang.p hp.

I am having a problem with getting a post from a dropdownlist off a
html form. While debugging, by instruction steps, for some reason I
am never get passed the isset($_POST['author_pk']) after selecting an
item in the dropdownlist.
.... and after a submit I assume, Peter made a good point ...

print_r($_POST) and see what it containts.

Grtz,
--
Rik Wasmus
Jul 15 '06 #3
Rik wrote:
IchBin wrote:
>I am cross posting to comp.lang.php and alt.comp.lang.p hp.

I am having a problem with getting a post from a dropdownlist off a
html form. While debugging, by instruction steps, for some reason I
am never get passed the isset($_POST['author_pk']) after selecting an
item in the dropdownlist.

... and after a submit I assume, Peter made a good point ...

print_r($_POST) and see what it containts.

Grtz,
You guys are right.. Originally I was tying to do this with javascript
and wanted to, onClick= event, post the selected field. I am use to java
Objects and their events and thought I could add the logic to post the
info from from the Dropdownlist and not need and submit button.
I am new to php\html objects and javascript. I am a java programmer and
learning your area. Some one in another thread mentioned that I could do
what I wanted with just PHP. He helped me out tremendously. I am
learning hour by hour.

I added the submit and all is well.

Thanks Guys.

IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Jul 15 '06 #4
IchBin wrote:
Rik wrote:
>IchBin wrote:
>>I am cross posting to comp.lang.php and alt.comp.lang.p hp.

I am having a problem with getting a post from a dropdownlist off a
html form. While debugging, by instruction steps, for some reason I
am never get passed the isset($_POST['author_pk']) after selecting an
item in the dropdownlist.

... and after a submit I assume, Peter made a good point ...

print_r($_POST ) and see what it containts.

Grtz,

You guys are right.. Originally I was tying to do this with javascript
and wanted to, onClick= event, post the selected field. I am use to java
Objects and their events and thought I could add the logic to post the
info from from the Dropdownlist and not need and submit button.
I am new to php\html objects and javascript. I am a java programmer and
learning your area. Some one in another thread mentioned that I could do
what I wanted with just PHP. He helped me out tremendously. I am
learning hour by hour.

I added the submit and all is well.

Thanks Guys.

IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
IchBin:
You don't *have* to have a submit button. You can set the select to
submit for you. i.e. <select ... onclick="submit ()">

Maybe you already knew that but if you didn't it could help in your
design.

-david-

Jul 15 '06 #5
David Haynes wrote:
IchBin wrote:
>Rik wrote:
>>IchBin wrote:
I am cross posting to comp.lang.php and alt.comp.lang.p hp.

I am having a problem with getting a post from a dropdownlist off a
html form. While debugging, by instruction steps, for some reason I
am never get passed the isset($_POST['author_pk']) after selecting an
item in the dropdownlist.

... and after a submit I assume, Peter made a good point ...

print_r($_POS T) and see what it containts.

Grtz,

You guys are right.. Originally I was tying to do this with javascript
and wanted to, onClick= event, post the selected field. I am use to
java Objects and their events and thought I could add the logic to
post the info from from the Dropdownlist and not need and submit button.
I am new to php\html objects and javascript. I am a java programmer
and learning your area. Some one in another thread mentioned that I
could do what I wanted with just PHP. He helped me out tremendously. I
am learning hour by hour.

I added the submit and all is well.

Thanks Guys.

IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
______________ _______________ _______________ _______________ _______________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

IchBin:
You don't *have* to have a submit button. You can set the select to
submit for you. i.e. <select ... onclick="submit ()">

Maybe you already knew that but if you didn't it could help in your
design.

-david-
It is my own confusion between html and javascript. When I looked at
tutorials for html the onClick was not documented. When I look at some
Javascript 1.3 docs I saw a detail spec. So my assumption, before you
replied to my first thread message, as that the onClick was a javascript
attribute. Which now does not make sense.

And yes that makes a world of difference in design.

Thanks David

IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
_______________ _______________ _______________ _______________ ______________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Jul 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3825
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of available articles ("availableItems") and a list of articles already in an issue ("selectedItems"). What I want is to be able to move articles freely between the two lists and then on submission add them to the issue (which I can), but also move...
1
2420
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php method=post > <select name= "name">
6
2411
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets say I have values selected for all three pull down menus. When I change the first "top-level" menu I want to reset both the second and third menus to the "default" state.
6
13029
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this is not an ASP.NET related question, but I know this group is knowledgeable and quick with responses. Thanks
5
1310
by: D | last post by:
Hi, I have created a contact form in php for contact information and have amde the e-mail a required field (requires you to input at least the "@") It works fine, but every once in a while I get blank e-mails with this in the "from" field: From: <>
5
2474
by: Sonnich | last post by:
Can anyone give me a quick hint for this? Say, I have: <SELECT NAME="opt3" SIZE="15" multiple> Then I'd like to list the items selected... echo $_POST; but this gives only the first one how do I get the rest?
3
3386
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
14
9267
by: The Natural Philosopher | last post by:
This is a nasty one and I can't see my way out of it. I have a bunch of select statements in a form, and each select statement has an onchange="do_something(this)" in it, and this works nicely..except when there is only ONE OPTION in a given select. It seems you cannot 'onchange' a single option! Well, that is reasonable. The trouble is I have no way of selecting it since the form itself is a
5
1719
by: Alan M Dunsmuir | last post by:
I have a Form with a <SELECTtab, its <OPTIONtabs generated by records in a database table using PHP5 and a 'SELECT' query. The values displayed are chosen to be recognisable to the users (they are in fact a list of names), but the data I need to process in the post-back come from other related fields in the same database record. I'm clearly missing something very basic here. How do I access these fields after the selection has been...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10285
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,...
0
10063
tracyyun
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...
0
9115
agi2029
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...
0
6838
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();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4270
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
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.