473,243 Members | 1,603 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,243 software developers and data experts.

retaiing values when resubmitting a page

Hello

does anyone know how I can retain values of a radio button and text in a
text box on a page when I use $_SERVER['PHP_SELF'] to requery a page? Im
sure Ive seen this done before but cant find the code

Thanks
Ian
May 29 '06 #1
3 1097
Ian Davies wrote:
Hello

does anyone know how I can retain values of a radio button and text in a
text box on a page when I use $_SERVER['PHP_SELF'] to requery a page? Im
sure Ive seen this done before but cant find the code

Thanks
Ian


The radio button and text are contained within a <form></form> tag set.
The <form> tag will have either method="GET" or method="POST"

If method="GET", you can read back the values using:
$foo = $_GET['foo'] where 'foo' is the name of your radio selector or
text field.

If method="POST", you can read back the values using:
$foo = $_POST['foo'];

-david-

May 29 '06 #2
inside the tag for the textarea, the value attribute should be set to a
snippet of php which echo's (or prints) the value of the posted
variables. If nothing has been submitted, then nothing will be echoed,
and the box will appear empty. if something was submitted, it will be
echoed back into the box. A similar idea applies to radio and
checkboxes, but it's SLIGHTLY more dificult because you have to
determine (using if conditionals) which button it should be set to.

May 29 '06 #3
thanks
I found a solution. posted below incase anyone else is interested

at top of page
session_start();
$_SESSION['mytextbox'] = trim($_POST['mytextbox']);
$_SESSION['myradiobutton'] = trim($_POST['myradiobutton']);

for the textbox
input name="mytextbox" type="text" value="<?php echo
$_SESSION['mytextbox'];?>"

for the radiobutton
input <?php if (!(strcmp($_SESSION['myradiobutton'],"1"))) {echo "CHECKED";}
?> name="myradiobutton" type="radio" value="yourcheckedvaluehere"

ian
"dimo414" <di*****@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
inside the tag for the textarea, the value attribute should be set to a
snippet of php which echo's (or prints) the value of the posted
variables. If nothing has been submitted, then nothing will be echoed,
and the box will appear empty. if something was submitted, it will be
echoed back into the box. A similar idea applies to radio and
checkboxes, but it's SLIGHTLY more dificult because you have to
determine (using if conditionals) which button it should be set to.

May 29 '06 #4

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

Similar topics

5
by: James Baker | last post by:
I have a form that has a dropdown list that will cause a post to the same page when it's changed. The problem I'm running into is that all of the controls reset to their default values (obviously...
6
by: brian_mckracken | last post by:
This might not be the right group for this question, since its kind of a pure html question... Given the html construct: <form action='index.php?expand=0,10000' method='post'> Email: <input...
5
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.net / VB page with a Script (submitValues) and a Form. 1. The form has 20 input texts and a "Submit" button. 2. The script declares 20 variables. The value of each...
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
4
by: keithb | last post by:
A page uses query string values to add a record to a database. The record should be added only once; however, if a user activates the url additional times, multiple records are added. Is there some...
3
by: lilOlMe | last post by:
I'm using Ajax to help make my webpage appear to be smoother. When a control has submitted, I would like to prevent any controls within that control from resubmitting until the request has...
0
by: Anup Daware | last post by:
Hi All, I am facing this very weird issue, for every server request my control is redirecting to the login page and again coming back to the actual page from where the request was initiated when I...
4
by: thete | last post by:
how to avoid resubmitting the form in php
5
by: Hans Kesting | last post by:
Hi, Is there good information about the asp.net page lifecycle in combination with dynamically loaded controls? Or on "how to build dynamic controls"? I keep hitting problems where values are...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.