41 users online (0 members and 41 guests)  


  Results 1 to 4 of 4

Related

  1. Replies: 4
  2. Replies: 3
  3. Web Radio    Forum: HTML Forum
    Replies: 0
  4. web radio    Forum: Javascript Forum
    Replies: 2
  5. Replies: 1
  1. #1
    ainoy31's Avatar
    New User

    Status
    Offline
    Join Date
    May 2007
    Posts
    6

    Radio Button in PHP

    Hello-
    I am using a radio button to make a selection and have the info selected be passed to the next page that will be inserted into a database. The info being passed will have the person's first and last name, email address, telephone, cell phone, job description, and price quoted. Any suggestions would be appreciated.

    Thx, AM

  2. #2
    firmaterra's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    81

    Re: Radio Button in PHP

    just cycle through the information and pass it to the DB. I presume all variables are passed onto the current page so you could have:
    //presuming users table
    $sql="INSERT in USERS .....";
    then execute sql statement.
    Remember to sanitize all user information FIRST!!

  3. #3
    ainoy31's Avatar
    New User

    Status
    Offline
    Join Date
    May 2007
    Posts
    6

    Re: Radio Button in PHP

    This is my file where the radion button is:

    Code:
    <?php
    require("ConnectDB.php");
    $select = $_POST['select'];
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Database Output</title>
    </head>
    <body bgcolor="#FF6600">
    <form action = "CompletedGreet.php" method = "post">
    <?php
     
     
    $query = "SELECT * FROM customer WHERE Customer_ID = '$select'";
    $result = mysql_query($query) or die(mysql_error());
    $num = mysql_numrows($result);
     
    echo "<b><center><h1>Pending Customer Database</h1></center></b><br>";
    ?>
    <table align = "center" border = "5" bordercolor = "maroon" bgcolor = "silver" cellspacing = "5" cellpadding = "10" width = "95%">
    <tr>
     
    <th align = "center"><font face = "Ariel, Helvetica, sans-serif">Name</font></th>
    <th align = "center"><font face = "Ariel, Helvetica, sans-serif">E-Mail Address</font></th>
    <th align = "center"><font face = "Ariel, Helvetica, sans-serif">Telephone</font></th>
    <th align = "center"><font face = "Ariel, Helvetica, sans-serif">Mobile</font></th>
    <th align = "center"><font face = "Ariel, Helvetica, sans-serif">Work Description</font></th>
    </tr>
    <?php
    $i = 0;
    while ($i < $num)
    {
    $first = mysql_result($result, $i, "First_Name");
    $last = mysql_result($result, $i, "Last_Name");
    $email = mysql_result($result, $i, "Email_Address");
    $phone = mysql_result($result, $i, "Telephone");
    $mobile = mysql_result($result, $i, "Mobile");
    $work = mysql_result($result, $i, "Work_Description");
    ?>
     
    <tr>
    <td align = "center"><font face = "Ariel, Helvetica, sans-serif"><input type = "radio" name = "person"><? echo $first. " " .$last;?></font></td>
    <td align = "center"><font face = "Ariel, Helvetica, sans-serif"><? echo $email;?></font></td>
    <td align = "center"><font face = "Ariel, Helvetica, sans-serif"><? echo $phone;?></font></td>
    <td align = "center"><font face = "Ariel, Helvetica, sans-serif"><? echo $mobile;?></font></td>
    <td align = "center"><font face = "Ariel, Helvetica, sans-serif"><? echo $work;?></font></td> 
    </tr>
     
     
    <?
    $i++;
    }
    echo "</table>";
    ?>
     
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <table align ="center">
    <tr>
    <td><b>Please enter the quote price for customer:</b></td><td><input type = "text" name = "price" size ="7"></td>
    </tr>
    </table>
    <br>
    <br>
    <table align = "center">
    <tr>
    <td align = "center"><input type = "Submit" name = "Select" value = "Submit"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    The price gets submitted to the next page and inserted into the database but the person info does not. Here is the next page where I am posting the variables and insertng it into the database. I am probably doing something stupid.
    thx. am
     
    <?php
    require("ConnectDB.php");
    $price = $_POST['price'];
    echo $price;
    $select = $_POST['person'];
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Completed Quote</title>
    </head>
    <body>
    <?
    $sql = "SELECT * FROM customer WHERE Customer_ID = '$select'";
    $result = mysql_query($sql, $connection) or die(mysql_error());
     
     
    $num = mysql_numrows($result);
    echo $num;
    ?> 
    <? 
    $i = 0;
    while($i < $num)
    {
    $first = mysql_result($result, $i, "First_Name");
    $last = mysql_result($result, $i, "Last_Name");
    $email = mysql_result($result, $i, "Email_Address");
    $phone = mysql_result($result, $i, "Telephone");
    $mobile = mysql_result($result, $i, "Mobile");
    $job = mysql_result($result, $i, "Work_Description");
     
    $i++;
    }
    ?>
    <?
    $sql = "INSERT INTO `completed`(`First_Name`, `Last_Name`, `Email_Address`, `Telephone`, `Mobile`, `Work_Description`, `Quoted_Price`) VALUES ('$first', '$last', '$email', '$phone', '$mobile', '$job', '$price')";
    if(!mysql_query($sql, $connection))
    {
    die('Error: ' . mysql_error());
    }
    ?>
    <table align = "center" border = "5" bordercolor = "maroon" bgcolor = "silver" cellspacing = "5" cellpadding = "10" width = "35%">
    <tr>
    <th align = "center">
    <?
    echo "Record has been updated with the quoted price. Do not forget to contact customer with the quoted price!"; 
    header("Refresh: 5; url = PendingCustomerInfo.php");
    ?>
    </th>
    </tr>
    </table>
    </body>
    </html>
    Last edited by vinyl-junkie; 05-29-2007 at 07:25 PM. Reason: Added code tags

  4. #4
    jobmaster's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2009
    Posts
    1

    Re: Radio Button in PHP

    Hi

    Thanks for your information........



Tags for this Thread