473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1100
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...
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
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
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.