Jump to content


Photo

sessions and cheek box in php please help cheers.


  • Please log in to reply
9 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 September 2006 - 12:47 PM

Advance thank you.

Can you kindly show me how to use sessions to keep the information that the user has pressed cheers.

So if the user get a error meesage when that user goes back to the page the checkbox/radio is a kept value cheers.

<? Session_start();
?>
<table width="550" align="center" border="4" bordercolor="black">
<td align="center">
<br>
<b><font color="blue">Please let users no the <font color="red">payment 
    method</font> you accept</font></b>
    <table width="525" align="center" border="4" bordercolor="black">
      <td align="center"> <p><b><font color="blue">Paypal</font></b> <br>
          <input type="radio" name="paypal1" value="yes" checked>
          yes 
          <input type="radio" name="paypal1" value="no">
          no<br>
          <br>
          <b><font color="blue">Cheek</font></b> <br>
          <input type="radio" name="cheek" value="yes" checked>
          yes 
          <input type="radio" name="cheek" value="no">
          no <br>
          <br>
          <b><font color="blue">Bank transfer</font></b> <br>
          <input type="radio" name="bank_transfer" value="yes" checked>
          yes 
          <input type="radio" name="bank_transfer" value="no">
          no <br>
        </p>
      <td align="center"> <p><b><font color="blue">Postal order</font></b> <br>
          <input type="radio" name="postal_order" value="yes" checked>
          yes 
          <input type="radio" name="postal_order" value="no">
          no <br>
          <b><font color="blue"><br>
          </font></b> <b><font color="blue">Cash via post</font></b> <br>
          <input type="radio" name="cash" value="yes" checked>
          yes 
          <input type="radio" name="cash" value="no">
          no <br>
          <b><font color="blue"><br>
          </font></b> <b><font color="blue">Credit card</font></b> <br>
          <input type="radio" name="credit_card" value="yes" checked>
          yes 
          <input type="radio" name="credit_card" value="no">
          no <br>
        </p></td>
      <br>
    </table></td></table>

example only
test.php
<?php session_start();

$paypal1=$_SESSION['paypal1']=$paypal_yes;
$paypal1=$_SESSION['paypal1']=$paypal_no;

echo "<a href='test_result.php'>cheek the session for radio box</a>";
?>

test_result.php
<?php session_start();?>
<form action="test.php method="POST">
<input type="radio" name="paypal1" value="<?php echo $paypal_yes;?>" checked>yes 
<input type="radio" name="paypal1" value="<?php echo $paypal_no;?>">no
<br>
<input type="submit" name="submit" value="send">
</form>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 September 2006 - 01:36 PM

can it be done becouse i am going mad i tried this but no joy

i have tried for hours please help
<?php session_start();
echo "<a href='url2.php'>cheek the session for radio box</a>";
?>

<?php session_start();

$no="no";
$yes="yes";

if($paypal1=="yes"){
$_SESSION['yes']=$yes;
}elseif(paypal1=="no"){
$_SESSION['no']=$no;
}

?>

<form action="url.php" method="POST">
<input type="radio" name="paypal1" value="<?echo $yes;?>" checked>yes 
<input type="radio" name="paypal1" value="<?echo $no;?>">no
<br>
<input type="submit" name="submit" value="send">
</form>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 11 September 2006 - 01:44 PM

Can you explain a little better... when you say "the user goes back to the page"... using the back button or your navigation?

Info: PHP Manual


#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 September 2006 - 01:51 PM

I am trying to get the radio box to keep its vaule with a session.

so if the user goes to another page the radio box keeps it value of yes or no

there will be a link for the user to go back to the page they came from

cheers

the whole idear is when a user uses the radio box to ansaw a quistion the radio box keeps it's value incase the user has an error as the code i am programming is a registartion and quistions.

if the user gets the ansaw wrong then i need the current radio box with the users information




Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 11 September 2006 - 02:02 PM

<?php

echo '<input type="radio" name="radio1" value="radio1_value" '

if (!empty($_SESSION['radio1'])) echo 'checked="checked" ';

echo '/>';

?>


#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 September 2006 - 02:07 PM

jenk are you drunk becouse how will that code you provided me help cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 11 September 2006 - 02:15 PM

what jenk is trying to get at, i think, is the basic premise behind radio buttons. i would modify his code slightly, though, because we're dealing with radio buttons and not checkboxes. you've got to see if the $_POST variable holds the current radio button's value and then "check" the one that is corresponding. so, take this basic example and see if it gives you some understanding:
<form name="test" action="" method="post">
<?php
$options = array(1,2,3,4,5,6,7,8,9,10);
foreach ($options as $option) {
  echo "<input type=\"radio\" name=\"myTest\" value=\"$option\"";
  if (isset($_POST['myTest']) && $_POST['myTest'] == $option) echo ' checked="checked"';
  echo " /> $option<br />\n";
} 
?>
<input type="submit" name="submit" value="Remember!" />
</form>

hope this helps
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 September 2006 - 02:21 PM

obsidian thank you for the code m8 but i need a slitly more advance way.


obsidian can you see my problam i got the first post shows the form i am working with i need to get some how the value of yes or no echoed within a page but with sessions becouse if there an error then the user does not have to do the radio agin as the session will keep the value.

i can keep the value but i need to keep the value within a session.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 11 September 2006 - 02:32 PM

for christ sake man! Assign the variable to the session array, then use isset() or empty() to verify if there is a value, if there is echo checked="checked" to pre-select the radio button.

Really, we are prepared to provide you with food, put it on your plate, hell even feed it to you, but YOU must be the one to chew!

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 September 2006 - 02:34 PM

well i can not get it going so can you do the above form so i can learn from it sorry for the not no cheers.



give me a proper example as the one above does not work for me ok.

try to give an example from my code as posted from first post thank you.

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users