Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: php radio button link  (Read 5400 times)

0 Members and 1 Guest are viewing this topic.

12Strings

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    php radio button link
    « on: April 25, 2016, 11:39:09 PM »
    I want to select a row from mysqli dropdown,
    click on button & link to "target"(format - www.somesite.com).
    change 2 fields in the sql (via lastused.php) code follows:
    My dropdown works, can't figure out the button code.
    My dropdown code follows:
    Any help?

    Code: [Select]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
            <head>

    <SCRIPT language=JavaScript>
    <!--  Clock --
    var timerID = null
    var timerRunning = false

    function stopclock()
       { if(timerRunning) clearTimeout(timerID) timerRunning = false }

    function startclock()
       { stopclock() showtime() }

    function showtime()
     {
        var now = new Date()
        var hours = now.getHours()
        var minutes = now.getMinutes()
        var seconds = now.getSeconds()
        var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
        timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
        timeValue  += (hours >= 12) ? " P.M." : " A.M."
        document.clock.face.value = timeValue
        timerID = setTimeout("showtime()",1000)
        timerRunning = true
     }
    //-->
    </SCRIPT>

    </head>
    <BODY onload="startclock()"><center>
    <FORM name=clock  method="post" action="" onsubmit=0>
    <INPUT size=11 value=....Initializing.... name=face>
    <FORM name=lastused method="post" action="">

        <?php
    echo 
    "<center>";echo date('m/d/y');echo "</center>";
    $id="''";
    $con=mysqli_connect("localhost","root","cookie","homedb");
    // ============== check connection
        
    if(mysqli_errno($con))
        {echo 
    "Can't Connect to mySQL:".mysqli_connect_error();}
        else
        {echo 
    "</br>";}
    // ==========This creates the drop down box using records in the table
           
    echo "<select name= 'target'>";
        echo 
    '<option value="">'.'---select email account ---'.'</option>';
        
    $query mysqli_query($con,"SELECT target FROM emailtbl");
        
    $query_display mysqli_query($con,"SELECT * FROM emailtbl");
        while(
    $row=mysqli_fetch_array($query))
        { echo 
    "<option class=highlight value='"$row['target']."'>".$row['target']
        .
    '</option>';}
        echo 
    '</select>';
        
    ?>

    <input type="submit" name="submit" value="Submit"/>
        </form>
              <?php
    nclude
    ('lastused.php'); // ********* code follows ******************
       
    error_reporting(E_ALL E_NOTICE);
    // error_reporting(0);
        
    $con=mysqli_connect("localhost","root","cookie","homedb");
        if(
    mysqli_errno($con))
        {echo 
    "Can't Connect to mySQL:".mysqli_connect_error();}
            if(isset(
    $_POST['target']))
      {
        
    $id $_POST['id'];
        
    $lastused $_POST['lastused']; 
        
    $name $_POST['target'];
        
    $fetch="SELECT target, username, password, emailused, lastused, purpose, saved FROM emailtbl WHERE target = '".$name."'";
        
    $result mysqli_query($con,$fetch);
        if(!
    $result)
        {echo 
    "Error:".(mysqli_error($con));}

    // =============================== this displays the table

        
    echo '<table border="1">'.'<tr>'.'<td bgcolor="#FFD47F" align="center">''email menu''</td>'.'</tr>';
        echo 
    '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'<td bgcolor="#ccffff">'.'target'.'</td>'.'<td bgcolor="#ccffff">'.'username'.'</td>'.'<td bgcolor="#ccffff">''password' .'</td>'.'<td bgcolor="#ccffff">''emailused''</td>'.'<td bgcolor="#FFD47F">''lastused' .'</td>'.'<td bgcolor="#ccffff">''purpose''</td>'.'<td bgcolor="#ccffff">''saved' .'</td>'.'</tr>';
            while(
    $data=mysqli_fetch_row($result))
        {echo (
    "<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>$data[5]</td><td>$data[6]</td></tr>");}
        echo 
    '</table>'.'</td>'.'</tr>'.'</table>';
      }
        
    ?>

        </body></html>
    =======================================================
    Code: [Select]
    <?php
    // lastused.php
    $dbconnect mysqli_connect('localhost','root','cookie')or die(mysqli_error($dbconnect));
    $result mysqli_query($dbconnect"SELECT * FROM emailtbl");
    if (!empty(
    $_POST['lastused']))
     {
        
    $update mysqli_query($dbconnect"UPDATE emailtbl SET visits = visits + 1, 
    lastused = 'NOW()' WHERE lastused ='
    $lastused'");
        if(
    $update == false)
        { die(
    "UPDATE FAILED: ".mysqli_error($dbconnect)); }
     }
      
    ?>