Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. [code]
    <?php
    // connect to database.

    $select = mysql_query("SELECT * FROM `table_name`");
    echo "<table><tr><td>Week</td><td>Date Start</td><td>Notes</td><td>Date End</td></tr>";
    while ($info = mysql_fetch_assoc($select)) {
    $week = $info['week'];
    $date_start = $info['date_start']; 
    $notes = $info['notes'];
    $date_end = $info['data_end'];

    echo "<tr>
    <td>
    $week
    </td>
    <td>
    $date_start
    </td>
    <td>
    $notes
    </td>
    <td>
    $date_end
    </td></tr>";
    }

    mysql_free_result($select);
    echo "</table>";
    ?>
    [/code]
  2. Might I note you should connect to your database (update):

    [code]
    <?php
    $ipaddy = $_SERVER['REMOTE_ADDR'];
    $ipaddy = str_replace(".","",$ipaddy);
    $connect = mysql_connect(host,dbuser,dbpass);
    $db = mysql_select_db(dbname,$connect);
    $query = "SELECT ip FROM ipbase WHERE ip=$ipaddy";
    $result = mysql_query($query) or die("mysql error: " . mysql_error());
    $line = mysql_fetch_assoc($result);
    $ipad = $line['ip'];
    if ( $ipad == $ipaddy ){
    echo 'Welcome!';
    $query = "INSERT INTO `ipbase` (`ip`) VALUES('$ipaddy')";
    $result = mysql_query($query) or die(mysql_error());
    }else {
    echo "&nbsp;";
    };
    ?>
    [/code]
  3. try this:

    [code]
    <?php
    $ipaddy = $_SERVER['REMOTE_ADDR'];
    $ipaddy = str_replace(".","",$ipaddy);
    $query = "SELECT ip FROM ipbase WHERE ip=$ipaddy";
    $result = mysql_query($query) or die("mysql error: " . mysql_error());
            $line = mysql_fetch_assoc($result);
    $ipad = $line['ip'];
    if ( $ipad == $ipaddy ){
    echo 'Welcome!';
    $query = "INSERT INTO `ipbase` (`ip`) VALUES('$ipaddy')";
    $result = mysql_query($query) or die(mysql_error());
    }else {
    echo "&nbsp;";
    };
    ?>
    [/code]
  4. [code]
    <?php
    $ipaddy = $_SERVER['REMOTE_ADDR'];
    $ipaddy = str_replace(".","",$ipaddy);
    $query = "SELECT ip FROM ipbase WHERE ip=$ipaddy";
    $result = mysql_query($query) or die("mysql error: " . mysql_error());
    while ($line = mysql_fetch_assoc($result)) {
    $ipad = $line['ip'];
    if ( $ipad == $ipaddy ){
    echo 'Welcome!';
    $query = "INSERT INTO `ipbase` (`ip`) VALUES('$ipaddy')";
    $result = mysql_query($query) or die(mysql_error());
    }
    else
    {
    echo "";
    }
    }
    mysql_free_result($result);
    ?>
    [/code]

  5. Alright
    [code]
    <?php
    session_start();
    $un = $_POST[Username];
    $_SESSION['Username'] = $un;


    $con = mysql_connect(host,dbuser,dbpass);
    $db = mysql_select_db(dbname,$con);

    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    $sql = "INSERT INTO Usagers (`Username`) VALUES('$un')";
    $result = mysql_query($sql);

    mysql_close($con);


    ?>
    [/code]

    if session username and post username are the same, why not just insert post username into the database?
×
×
  • 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.