473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 16255
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_goes_here]">
<select name="mySelect" id="mySelect"
onChange="mySelect.form.submit()">
<option value="">Select an option
<option value="1">Option 1
<option value="2">Option 2
<option value="3">Option 3
<option value="4">Option 4
</select>
</form>

Cheers,
NC

Jul 20 '07 #2
NC <nc@iname.comwrote in news:1184973751.142209.176900
@d30g2000prg.googlegroups.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_goes_here]">
<select name="mySelect" id="mySelect"
onChange="mySelect.form.submit()">
<option value="">Select an option
<option value="1">Option 1
<option value="2">Option 2
<option value="3">Option 3
<option value="4">Option 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***********************@roadrunner.comwrote:
>| NC <nc@iname.comwrote in news:1184973751.142209.176900
| @d30g2000prg.googlegroups.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_goes_here]">
| <select name="mySelect" id="mySelect"
| onChange="mySelect.form.submit()">
| <option value="">Select an option
| <option value="1">Option 1
| <option value="2">Option 2
| <option value="3">Option 3
| <option value="4">Option 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("SELECT * 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("location: pag2.php");

This is provided you haven't sent any information to the browser
already.
-- -------------------------------------------------------------
jn******@yourpantsyahoo.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("location: pag2.php");
header("Location: 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*******@attglobal.net
==================
Jul 21 '07 #7
Jerry Stuckle <js*******@attglobal.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("location: pag2.php");

header("Location: 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("location: pag2.php");

header("Location: 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.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 21 '07 #10
bill wrote:
Michael Fesser wrote:
>header("Location: http://{$_SERVER['HTTP_HOST']}/pag2.php");
The URL must be absolute.

why ?
HTTP/1.1 spec says so.

Most browsers do support relative URLs in Location headers, but it's unwise
to rely on that.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 30 days, 17:58.]

Parsing an HTML Table with PEAR's XML_HTTPSax3
http://tobyinkster.co.uk/blog/2007/0...table-parsing/
Jul 21 '07 #11
Toby A Inkster wrote:
bill wrote:
>Michael Fesser wrote:
>>header("Location: http://{$_SERVER['HTTP_HOST']}/pag2.php");
The URL must be absolute.
why ?

HTTP/1.1 spec says so.

Most browsers do support relative URLs in Location headers, but it's unwise
to rely on that.
Thanks to you both.
Jul 22 '07 #12
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
You're looking for a Javascript solution - client side, you know.
There's a submit() function that you can programatically fire in JS to
have the page submit a form.

<a href="javascript:submit();">Submit</a>

It'll retain that hyperlink look and feel, but actually be a post
instead of a get.


Aug 3 '07 #13

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

Similar topics

6
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...
1
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...
17
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
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...
6
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...
3
by: JimO | last post by:
Is there a way to force a post without using submit button? Thanks, Jim
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I POST a form to a new window? ----------------------------------------------------------------------- ...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I POST a form to a new window? ----------------------------------------------------------------------- ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.