コード例 #1
0
<?php

$conexion = mysqli_connect('localhost', 'root', '', 'intranet') or die("Error en la coneccion" . myqli_error($conexion));
$query = "select * from usuarios;";
$resultado = mysqli_query($conexion, $query);
echo "<table border=1>\n\t\t<tr>\n\t\t\t<td>Usuario</td>\n\t\t\t<td>Clave</td>\n\t\t</tr>";
while ($registro = mysqli_fetch_row($resultado)) {
    echo '<tr>
			<td>' . $registro[0] . '</td>
			<td>' . $registro[1] . '</td>
		</tr>';
}
echo '</table>';
$query2 = "select * from datospersonales;";
$resultado2 = mysqli_query($conexion, $query2);
echo "<table border=1>\n\t\t<tr>\n\t\t\t<td>Usuario</td>\n\t\t\t<td>Nombre</td>\n\t\t\t<td>Email</td>\n\t\t</tr>";
while ($registro2 = mysqli_fetch_row($resultado2)) {
    echo '<tr>
			<td>' . $registro2[0] . '</td>
			<td>' . $registro2[1] . '</td>
			<td>' . $registro2[2] . '</td>
		</tr>';
}
echo "</table><br><a href='consulta5-1.php'>actualizar</a>";
コード例 #2
0
    } else {
        echo "Error creating database:" . mysqli_error($conn);
    }
    mysqli_select_db($conn, $database) or die("Unable to select database");
}
$queryCreateProfilesTable = "CREATE TABLE IF NOT EXISTS `profiles` (`id` int(11) unsigned NOT NULL PRIMARY KEY auto_increment, `firstName` text, `lastName` text, `address` varchar(50), `city` text, `pcode` int(11), `phone` int(11), `email` varchar(30), `cv` longblob)";
// check if the profiles table exits or not. If not, create a new profile table.
if (mysqli_query($conn, $queryCreateProfilesTable)) {
} else {
    echo "Error creating profiles table:" . mysqli_error($conn);
}
$queryCreateAdminTable = "CREATE TABLE IF NOT EXISTS `admin` (`admin` text, `password` varchar(100))";
// check if the admin table exits or not. If not, crate a new admin table.
if (mysqli_query($conn, $queryCreateAdminTable)) {
} else {
    echo "Error creating admin table:" . mysqli_error($conn);
}
$check = "SELECT * FROM `admin`";
$check1 = mysqli_query($conn, $check);
$rows = mysqli_num_rows($check1);
if (!$rows) {
    // entering the log in credentials of the admin into the database.
    $ausername = "******";
    $apassword = "******";
    $queryCred = "INSERT INTO `admin` VALUES('" . $ausername . "','" . md5(md5($ausername) . $apassword) . "')";
    // .md5(md5($_POST['email']).$_POST['password']).
    if (mysqli_query($conn, $queryCred)) {
    } else {
        echo "Error entering values:" . myqli_error($conn);
    }
}
コード例 #3
0
<?php

include 'database.php';
?>

<?php 
if (isset($_POST['name']) && isset($_POST['shout'])) {
    $name = mysqli_real_escape_string($con, $_POST['name']);
    $shout = mysqli_real_escape_string($con, $_POST['shout']);
    $date = mysqli_real_escape_string($con, $_POST['date']);
    //Set timezone
    date_default_timezone_set('America/Los_Angeles');
    $date = date('h:i:s: a', time());
    $query = "INSERT INTO shouts (name, shout, date)\n    VALUES ('{$name}', '{$shout}', '{$date}')";
    if (!mysqli_query($con, $query)) {
        echo 'Error: ' . myqli_error($con);
    } else {
        echo '<li>' . $name . ': ' . $shout . ' [' . $date . ']</li>';
    }
}