Results 1 to 5 of 5

Thread: Retrieve information with radio buttons

  1. #1
    Join Date
    Nov 2008
    Posts
    1,022

    Retrieve information with radio buttons

    I created a site with the help of HTML and PHP for myself to maintain database.

    On my site, I have a form that has 3 radio buttons (1 for "Request for appointment", 2 for "Request for information", 3 for other purposes).

    Everything is ok except for radio buttons.

    My HTML code for the form:

    HTML Code:
      <FORM Method= "POST" action= "do_sendform.php" name= "Contact"> 
          <p align= "center"> <font face= "Bell Gothic Std Black"> Reason for contact: </font> </p> 
          <p align= "center"> 
    	  <input type= "radio" name= "DemandYou" value= "Demand meeting you"> <font face= "Bell Gothic Std Black"> Application for appointment</font> 
    	  <input type= "radio" name= "Intelligence" value= "Intelligence"> <font face= "Bell Gothic Std Black"> Inquiry </font> 
    	  <input type= "radio" name= "Other" value= "Other"> <font face= "Bell Gothic Std Black"> Other: </font> <input type= "text" name= "Other"> </p> 
          <p align= "center"> <font face= "Bell Gothic Std Black"> Your First & Last Name: </font> <br> 
      <INPUT Type= "text" name= "sender_name" size= 30> 
      </p> 
          <p align= "center"> <font face= "Bell Gothic Std Black"> Your email address: </font> <br> 
      <INPUT Type= "text" name= "sender_email" size= 30> 
      </p> 
          <p align= "center"> <font face= "Bell Gothic Std Black"> Message: </font> <br> 
      <textarea name= "message" cols= "63" rows= "8"> </textarea> 
      </p> 
          <p align= "center"> <font face= "Bell Gothic Std Black"> <INPUT type= "submit" value= "SEND"> </font> </p> 
      </FORM>
    and the PHP code

    PHP Code:
      <?php 
      $msg 
    .= "Sender E-Mail: \t $sender_email \n"
      
    $msg .= "Message: \t $message \n \n"
      
    $recipient "xyz@gmail.com"
      
    $mailheaders "Need fragrance <> \n"
      
    $mailheaders .= 'Reply-to: $sender_email \n \n "; 
      $subject = "subject: $contact \n \n"; 

      Mail ($recipient, $subject, $msg, $mailheaders);  

      echo "<html> <head>"; 
      echo "<title> Need fragrance - Contacts </title> </head> <body>; 
      echo "<h1 align=center> THANKS, $sender_name </h1>"; 
      echo "<p align=center>"; 
      echo "Your mail has been sent. </p>"; 
      echo "</body> </html>"; 
      ?>
    I tried all the tests with the radio buttons but depending on the selected radio button, the subject of the email sent is changed to one of the 3 titles listed above.

  2. #2
    Join Date
    Feb 2008
    Posts
    194

    Re: Retrieve information with radio buttons

    Are the radio buttons of the same "name"? If yes then you can easily retrieve the "value" of the selected radio in $_POST ['name_of_radios']

  3. #3
    Join Date
    Nov 2008
    Posts
    1,022

    Re: Retrieve information with radio buttons

    I was just testing what you told me and it works. But I still have some questions:

    1. I added a text box for radio buttons. Is this possible, when this button is activated it retrieves the value of the text box?

    2. As soon as the form is valid, I come on a white page that returns a message to the user and say that the message was taken. I want to add a button over there namely "Back". Is it possible? How?

  4. #4
    Join Date
    Feb 2008
    Posts
    194

    Re: Retrieve information with radio buttons

    1 - Its very simple. If the third option is selected, you use the $_POST ['name_of_field'] to get its value.

    2 - I do not understand what you are trying to achieve.

  5. #5
    Join Date
    Nov 2008
    Posts
    1,022

    Re: Retrieve information with radio buttons

    1. Thanks for the solution

    2. Once the user clicked to send the form, with the help of php code, the user gets a message saying the message has been sent. The problem is that the only way to go back is to click on the button "Back" of the browser. I would like to add a button on this page to return for example on the home page?

Similar Threads

  1. Replies: 6
    Last Post: 01-07-2011, 10:21 PM
  2. Replies: 4
    Last Post: 16-12-2010, 10:26 PM
  3. VBSript - Fancy radio buttons
    By milnet in forum Software Development
    Replies: 3
    Last Post: 13-05-2010, 01:56 PM
  4. Convert information to radio button
    By KADEEM in forum Software Development
    Replies: 3
    Last Post: 31-10-2009, 02:47 PM
  5. How to retrieve information from delphi getappname method
    By Lord of the RIG in forum Software Development
    Replies: 3
    Last Post: 11-08-2009, 02:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •