473,404 Members | 2,195 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,404 software developers and data experts.

Passing on a value to a SUBMIT button - can it be done?

I'm creating an application with which I can update values in a MySQL
database.
Each row of the database table is a web page with a form. After updating the
fields, the new values are passed on the database table by pressing the
Submit-button. So far, no problems. Then I want to go on to the next page,
so I was hoping that something like this would work:

echo '<form method="GET" action ="de.php?pageno=5">';

But it doesn't. I keep on coming back to page 1.
What should I be doing?

Thanks, Marcel

Sep 30 '05 #1
6 5958
NC
Marcel wrote:

I'm creating an application with which I can update values in a MySQL
database.
Each row of the database table is a web page with a form. After updating the
fields, the new values are passed on the database table by pressing the
Submit-button. So far, no problems. Then I want to go on to the next page,
so I was hoping that something like this would work:

echo '<form method="GET" action ="de.php?pageno=5">';

But it doesn't. I keep on coming back to page 1.
What should I be doing?


You should define a hidden field somewhere in the form. Something
like this:

<input type="hidden" name="pageno" value="<?php
echo $_GET['pageno'];
?>">

Cheers,
NC

Sep 30 '05 #2
Hmmm... it appears you are fairly green at this :)

But anyway...

To move to another page you have a few options.

Option 1: Do your db operations on the page you are going to.

or

Option 2: Redirect from the page where you are currently performing your
Database operations, using header("Location: destination_page.php");

Hope that helps.

D.

Marcel wrote:
I'm creating an application with which I can update values in a MySQL
database.
Each row of the database table is a web page with a form. After updating the
fields, the new values are passed on the database table by pressing the
Submit-button. So far, no problems. Then I want to go on to the next page,
so I was hoping that something like this would work:

echo '<form method="GET" action ="de.php?pageno=5">';

But it doesn't. I keep on coming back to page 1.
What should I be doing?

Thanks, Marcel

Sep 30 '05 #3
> Marcel wrote:
I'm creating an application with which I can update values in a MySQL
database.
Each row of the database table is a web page with a form. After
updating the
fields, the new values are passed on the database table by pressing the
Submit-button. So far, no problems. Then I want to go on to the next
page,
so I was hoping that something like this would work:

echo '<form method="GET" action ="de.php?pageno=5">';
write echo '<form method="get" action="">'

and then change your code in de.php to
if(isset($_REQUEST['page'])){
//connect to your database
//query the database for page where id=the value in $_REQUEST['page']
//retreive html-page and display

}else{
//display normal de.php
}
But it doesn't. I keep on coming back to page 1.
What should I be doing?

Thanks, Marcel


There was a comment on hidden fields. Variables carried by urls are easy
to manipulate,
and although it looks cool (yes it does) perhaps you should avoid them.
Then the method is
post, not get, but the code in de.php remains (since you use the
REQUEST-method which accepts both POST and GET)
Sep 30 '05 #4
Marcel wrote:
<form method="GET" action ="de.php?pageno=5">


I can't see anything in the HTML4.01 spec which forbids this. It's
valid, that's easily checkable; it also complies with at least one
reading of the prose. What's left is to see what browsers make of it.

On submission, according to the spec, a question mark is appended to the
value of the action attribute and the form data set (name/value pairs) is
then appended. Here, the action URL already has a question mark, so
appending another question mark gives a URL with two question marks, e.g.

http://host.invalid/foo?bar=1?baz=2

If arg_separator is the ampersand '&', the first and second arguments will
combine and PHP will recognise only one variable: name 'bar', value
'1?baz=2'.

As to browsers, YMMV.

--
Jock
Sep 30 '05 #5

"Siv Hansen" <si**@broadpark.no> wrote in message
news:43********@news.broadpark.no...
Marcel wrote:
I'm creating an application with which I can update values in a MySQL
database.
Each row of the database table is a web page with a form. After
updating the
fields, the new values are passed on the database table by pressing the
Submit-button. So far, no problems. Then I want to go on to the next
page,
so I was hoping that something like this would work:

echo '<form method="GET" action ="de.php?pageno=5">';
write echo '<form method="get" action="">'

and then change your code in de.php to
if(isset($_REQUEST['page'])){
//connect to your database
//query the database for page where id=the value in $_REQUEST['page']
//retreive html-page and display

}else{
//display normal de.php
}
But it doesn't. I keep on coming back to page 1.
What should I be doing?

Thanks, Marcel


There was a comment on hidden fields. Variables carried by urls are easy
to manipulate,
and although it looks cool (yes it does) perhaps you should avoid them.
Then the method is
post, not get, but the code in de.php remains (since you use the
REQUEST-method which accepts both POST and GET)


Hello again,
I've been trying to implement what was said, but it just doesn't work here..
For the moment I go for the suggestion with a Hidden field in the form,
because that looks the most simple one, and I'm only using this application
at home, it's only for me and not for anybody else..
I'm testing this in IE6 with IIS.
Loading the page goes ok, and the pageno echoes as '1'.
Then I hit submit, the pageno echoes as blank and I get the following
notice: Notice: Undefined index: pageno in
c:\\inetpub\\wwwroot\\picdata\\de2.php on line 39

Here's the code:

<html>
<head>
<title>Picture data entry</title>
</head>
<body>
<div id="container">

<?php

/*initialize pageno */
/* if there is a pageno then it must be one higher then the last time */

if (isset($_GET['pageno']))
{
$pageno = $_GET['pageno'];
$pageno = $pageno++;
}
else
{
$pageno = 1;
}

echo "pageno :" . $pageno;
?>

<p>
<hr align = "left">
<table>
<tr>
<td align = "center" >
<img border = "0" src = "images/01bc11.jpg ">
</td>
<td>
<form method="GET" action ="de2.php?pageno=$pageno">
<input type="text" name="pictureid" value="pictureid" READONLY>
Picture ID <BR>
<input type="text" name="year" value="year" READONLY> Year <BR>
<input type="hidden" name="pageno" value="<?php echo $_GET['pageno'];
?>">

<p>
<input type="submit" name="submit" value="Submit">
</form>
</td>
</tr>
</table>
<hr align = "left">
</div>
</body>
</html>

Thanks for any suggestion...
Marcel
Oct 2 '05 #6
Marcel wrote:
"Siv Hansen" <si**@broadpark.no> wrote in message Hello again,
I've been trying to implement what was said, but it just doesn't work here..
For the moment I go for the suggestion with a Hidden field in the form,
because that looks the most simple one, and I'm only using this application
at home, it's only for me and not for anybody else..
I'm testing this in IE6 with IIS.
Loading the page goes ok, and the pageno echoes as '1'.
Then I hit submit, the pageno echoes as blank and I get the following
notice: Notice: Undefined index: pageno in
c:\\inetpub\\wwwroot\\picdata\\de2.php on line 39

Here's the code:

<html>
<head>
<title>Picture data entry</title>
</head>
<body>
<div id="container">

<?php

/*initialize pageno */
/* if there is a pageno then it must be one higher then the last time */
Here, you're checking whether there was a 'pageno' in the URL:
if (isset($_GET['pageno']))
{
$pageno = $_GET['pageno'];
$pageno = $pageno++;
}
else
{
$pageno = 1;
}

echo "pageno :" . $pageno;
?>

<p>
<hr align = "left">
<table>
<tr>
<td align = "center" >
<img border = "0" src = "images/01bc11.jpg ">
</td>
<td>
<form method="GET" action ="de2.php?pageno=$pageno">
<input type="text" name="pictureid" value="pictureid" READONLY>
Picture ID <BR>
<input type="text" name="year" value="year" READONLY> Year <BR>
but here, you're not checking it!
<input type="hidden" name="pageno" value="<?php echo $_GET['pageno'];
?>">

<p>
<input type="submit" name="submit" value="Submit">
</form>
</td>
</tr>
</table>
<hr align = "left">
</div>
</body>
</html>

Thanks for any suggestion...
Marcel


You also need to think about your line
$pageno = $pageno++;

The 'post-increment operator' ++ means 'change this variable by adding
1, and then return the previous value' - so the line above has no net
effect!

Colin
Oct 2 '05 #7

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

Similar topics

1
by: monika | last post by:
hi ... I have an asp page which has 3 buttons. <p align="center"><input class="button" type="button" onClick="location='welStudent.asp';" value="Click to write a new story"></p> <p...
3
by: Lukelrc | last post by:
Hi all, I have an asp page with a delete button which has an OnClick Ok/Cancel msgbox event. My problem is that in order to run the Onclick event i've chaged the buttons type from "Submit" to...
2
by: Les Peabody | last post by:
Hello. I'm a rookie ASP VBScripter and am having a difficult time scripting the following scenario: I have an index.asp file that has a multi-line text box and a button of type button. When...
5
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
5
by: manningfan | last post by:
I have a single form that I want to make as generic as possible. The form contains a Calendar control. Using OpenArgs I pass values from the form that's calling the calendar, and the field the...
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
1
by: satish2112 | last post by:
Hi, I have a text-area which contains values from mysql database and 2 buttons, Edit and Update. When I click on the Edit button, I can edit the text-area (initially non-editable). After this,...
8
by: ridgedale | last post by:
I wonder if anyone could explain how I pass the field values in my request form to the PHP processor page. My external javascript file is as follows: var sections = ; for (var i=0; i <...
5
by: Fran Jakers | last post by:
Hello all, I'm new to all this and I could really use some help. I've searched the web but cannot find an answer. I have an HTML form with 3 radio buttons and a search field that calls a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...
0
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...
0
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,...

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.