473,799 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can PHP Post without a form?

I have a dropdown list dynamically created in a form by PHP from a MySql
table. This is the only element on the page. For some records there is only
a single selection, and if that's the case I'd like to just post that and
go to the next page. Is there a simple way to do that using POST? I know
how to do it with GET, but don't like the resulting URLs.

Or is there a simpler method I'm not thinking about?

Thanks,
Larry
Jul 20 '07 #1
12 16283
NC
On Jul 20, 4:07 pm, "Larry L [in Honolulu]" <la...@no-place.org>
wrote:
>
I have a dropdown list dynamically created in a form
by PHP from a MySql table. This is the only element
on the page. For some records there is only a single
selection, and if that's the case I'd like to just
post that and go to the next page. Is there a simple
way to do that using POST?
Yes, but it's got nothing to do with PHP:

<form method="POST" action="[your_action_goe s_here]">
<select name="mySelect" id="mySelect"
onChange="mySel ect.form.submit ()">
<option value="">Select an option
<option value="1">Optio n 1
<option value="2">Optio n 2
<option value="3">Optio n 3
<option value="4">Optio n 4
</select>
</form>

Cheers,
NC

Jul 20 '07 #2
NC <nc@iname.comwr ote in news:1184973751 .142209.176900
@d30g2000prg.go oglegroups.com:
On Jul 20, 4:07 pm, "Larry L [in Honolulu]" <la...@no-place.org>
wrote:
>>
I have a dropdown list dynamically created in a form
by PHP from a MySql table. This is the only element
on the page. For some records there is only a single
selection, and if that's the case I'd like to just
post that and go to the next page. Is there a simple
way to do that using POST?

Yes, but it's got nothing to do with PHP:

<form method="POST" action="[your_action_goe s_here]">
<select name="mySelect" id="mySelect"
onChange="mySel ect.form.submit ()">
<option value="">Select an option
<option value="1">Optio n 1
<option value="2">Optio n 2
<option value="3">Optio n 3
<option value="4">Optio n 4
</select>
</form>

Cheers,
NC
Well thanks, but maybe I didn't explain it well enough. I have pretty
much exactly what you show, but sometimes when the page loads, and the
options list is created, there is only one item there. If that's the
case, then I don't want to even show it, I just want the one option
posted to the next page.

Larry
Jul 21 '07 #3
..oO(Larry L [in Honolulu])
>Well thanks, but maybe I didn't explain it well enough. I have pretty
much exactly what you show, but sometimes when the page loads, and the
options list is created, there is only one item there. If that's the
case, then I don't want to even show it, I just want the one option
posted to the next page.
In short: What kind of informations do you want to post to the next
page?

A bit longer: Sending a form to the client, just to have it posted back
immediately is not only really ugly, but also highly unreliable, since
it requires JavaScript. Dependent on the informations that have to be
sent around, there might be better ways (e.g. a server-side redirect,
sessions, CURL, ...)

Micha
Jul 21 '07 #4
On 21 Jul 2007 00:30:17 GMT, in comp.lang.php "Larry L [in Honolulu]"
<la***@no-place.org>
<46************ ***********@roa drunner.comwrot e:
>| NC <nc@iname.comwr ote in news:1184973751 .142209.176900
| @d30g2000prg.go oglegroups.com:
|
| On Jul 20, 4:07 pm, "Larry L [in Honolulu]" <la...@no-place.org>
| wrote:
| >>
| >I have a dropdown list dynamically created in a form
| >by PHP from a MySql table. This is the only element
| >on the page. For some records there is only a single
| >selection, and if that's the case I'd like to just
| >post that and go to the next page. Is there a simple
| >way to do that using POST?
| >
| Yes, but it's got nothing to do with PHP:
| >
| <form method="POST" action="[your_action_goe s_here]">
| <select name="mySelect" id="mySelect"
| onChange="mySel ect.form.submit ()">
| <option value="">Select an option
| <option value="1">Optio n 1
| <option value="2">Optio n 2
| <option value="3">Optio n 3
| <option value="4">Optio n 4
| </select>
| </form>
| >
| Cheers,
| NC
|
| Well thanks, but maybe I didn't explain it well enough. I have pretty
| much exactly what you show, but sometimes when the page loads, and the
| options list is created, there is only one item there. If that's the
| case, then I don't want to even show it, I just want the one option
| posted to the next page.
|
| Larry
PHP Manual example:
<?php
$link = mysql_connect(" localhost", "mysql_user ", "mysql_password ");
mysql_select_db ("database", $link);

$result = mysql_query("SE LECT * FROM table1", $link);
$num_rows = mysql_num_rows( $result);

echo "$num_rows Rows\n";
?>

instead of echoing the number you would use
if( $num_rows == 1 )
header("locatio n: pag2.php");

This is provided you haven't sent any information to the browser
already.
-- -------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Jul 21 '07 #5
..oO(Jeff North)
>instead of echoing the number you would use
if( $num_rows == 1 )
header("locatio n: pag2.php");
header("Locatio n: http://{$_SERVER['HTTP_HOST']}/pag2.php");

The URL must be absolute.

Micha
Jul 21 '07 #6
Larry L [in Honolulu] wrote:
I have a dropdown list dynamically created in a form by PHP from a MySql
table. This is the only element on the page. For some records there is only
a single selection, and if that's the case I'd like to just post that and
go to the next page. Is there a simple way to do that using POST? I know
how to do it with GET, but don't like the resulting URLs.

Or is there a simpler method I'm not thinking about?

Thanks,
Larry
If you really need to post the forum, check CURL.

OTOH, I might recommend you store the appropriate info in a session, and
change the target page to look for the data in the session, also.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 21 '07 #7
Jerry Stuckle <js*******@attg lobal.netwrote in
news:yd******** *************** *******@comcast .com:
OTOH, I might recommend you store the appropriate info in a session,
and change the target page to look for the data in the session, also.
Thanks Jerry, ultimately that's what I did, it took me a while to realize I
already had a session open which made it pretty easy.

Larry
Jul 21 '07 #8
Michael Fesser wrote:
.oO(Jeff North)
>instead of echoing the number you would use
if( $num_rows == 1 )
header("locatio n: pag2.php");

header("Locatio n: http://{$_SERVER['HTTP_HOST']}/pag2.php");

The URL must be absolute.
why ?

bill
Jul 21 '07 #9
On Sat, 21 Jul 2007 09:30:30 -0400, bill <no****@spamcop .netwrote:
>Michael Fesser wrote:
>.oO(Jeff North)
>>instead of echoing the number you would use
if( $num_rows == 1 )
header("locatio n: pag2.php");

header("Locati on: http://{$_SERVER['HTTP_HOST']}/pag2.php");

The URL must be absolute.

why ?
HTTP/1.1 section 14.30.
http://www.w3.org/Protocols/rfc2616/....html#sec14.30

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 21 '07 #10

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

Similar topics

6
6641
by: Angelos | last post by:
I have this list of logs stored in a MySQL DB. I display them in a list and next to each log I have a del view LINK I want to add Checkboxes next to each log and keep del and view links as well. Then you can select all the logs you want to delete, hit a delete Link and send the variables in a script... Can you do that without having a form ?
1
1628
by: Matt | last post by:
Is it possible to post the form data and open the page as a modal window? Because when I do the following, it will open page2.asp in a new window, but I still able to manipulate page1.asp. I want to make page2.asp as modal window. <form action="http://server2/page2.asp" method="post" target="_blank"> Any ideas?
17
1649
by: Justin | last post by:
How do I post a form to a specified url using an ASP.NET with a code behind? With traditional ASP I used to be able to simply use: action="https://www.domain.com/process.asp" Thanks, Justin.
8
5081
by: Gert | last post by:
Hi, I have a form (server side) because of the filling of variables through the application. But now I need to post it to an url on submit. My .HTML form looks like this, but how to translate it to asp.net vb code? !--<FORM ACTION="/test/test.php" METHOD=POST>--> <form action="https://multipay.net/transaction/mpmain.php" method="post"> ....
6
2461
by: Jason | last post by:
I have a sticky problem relating to my 'join' registration form inside our authenticatin system... We have just signed up for salesforce.com and I need to somehow integrate the canned web-to-lead form from salesforce inside my login/registraiton system without messing up the existing 'join' form. My registration form is built on top of database while the salesform form is statically generated form which is similiar but not exactly the...
3
6360
by: JimO | last post by:
Is there a way to force a post without using submit button? Thanks, Jim
4
2447
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I POST a form to a new window? ----------------------------------------------------------------------- You use the target attribute on the form, opening a window with that name and your feature string in the onsubmit handler of the FORM. <form ... target="wndname" onsubmit="window.open('',this.target,'features');return true;">
4
1418
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I POST a form to a new window? ----------------------------------------------------------------------- You use the target attribute on the form, opening a window with that name and your feature string in the onsubmit handler of the FORM. <form ... action="..." target="wndname" onsubmit="window.open('',this.target,'features');return true;">
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10491
Oralloy
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...
0
10268
jinu1996
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...
0
10031
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
9079
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...
1
7571
isladogs
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...
0
5467
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...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
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.