Jump to content

help with Radio button in php, html


kannu

Recommended Posts

hello,

I have a php, html page. I plan to use two radio buttons

 

echo" <input type='radio' name='payment_type' value='complete' checked> Complete

        <input type='radio' name='payment_type'  value='incom'>incom ";

 

I have a question:

 

Before the user exists this page, I want to check the value of the radio button and store it in the variable $selt

 

Can you please tell me how can I do the same.

sorry I am very novice in php

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/133058-help-with-radio-button-in-php-html/
Share on other sites

hello

thanks for the reply. yes, i would have to pass the status of the radio button to another page also. but before i do that, i would want to store the status of the radio button to the variable $selt in the same page also.

 

if you can please tell me how can i check the status of the radio button in another page, and how can i store its value to variable $selt in the same page.

 

thanks for help, i am really new in this.

echo" <form action="$_SERVER[php_SELF]"><input type='radio' id+payment_type1" name='payment_type1' value='complete' checked> Complete
        <input type='radio' name='payment_type2'  id="payment_type2" value='incom'>incom </form>";

 

above code will post the form data to the same page put put the below code before any html

 

<?php
$pt1 = $_POST['payment_type1'];
$pt2 = $_POST['payment_type2'];
selt = "-1";
if ($pt1=='complete') {
   $selt = $pt1;
} else if ($pt2=='incom') {
   $selt = $pt2;
}
$pta = array("complete","incom");
if (selt==$pta) {
   header("loaction: URL-TO-NEXT-PAGE-HERE?pt=".$selt);
}
?>

 

if complete is selected this will give you to a url of URL.php?pt=complete

 

in the next page you can call the status buy using $_GET['pt'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.