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
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.

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.