Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

php radio button link


  • Please log in to reply
1 reply to this topic

#1 12Strings

12Strings

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:12:33 PM

Posted 25 April 2016 - 11:45 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?
 

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

=======================================================

<?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)); }
 }
  ?>

 



BC AdBot (Login to Remove)

 


#2 12Strings

12Strings
  • Topic Starter

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:12:33 PM

Posted 27 July 2016 - 06:27 PM

<!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>
</head>
<BODY><center>
<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
include('connect-to-homedb.php');          
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'];
    $target = $_POST['target'];
    $fetch="SELECT target, username, password, purpose, emailused, visit-date,
    visit-count, visit-time, saved FROM emailtbl WHERE target = '$target'";
    $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">'. 'purpose'. '</td>'.'
<td bgcolor="#ccffff">'. 'emailused'. '</td>'.'
<td bgcolor="#FFD47F">'. 'visit-date' .'</td>'.'
<td bgcolor="#FFD47F">'. 'visit-count' .'</td>'.'
<td bgcolor="#FFD47F">'. 'visit-time' .'</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><td>$data[7]</td>
<td>$data[8]</td>'.'</tr>"); }
    echo '</table>'.'</td>'.'</tr>'.'</table>';
  }
    ?>
    </body></html>

=======================================================

<?php
include ('connect-to-homedb');
$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 visit-date = 'NOW()',
visit-count = 'visit-count + 1', visit-time = 'time()'
 WHERE target ='$target'");
    if($update == false)
    { die("UPDATE FAILED: ".mysqli_error($dbconnect)); }
 }
  ?>


Edited by 12Strings, 27 July 2016 - 06:30 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users