Pues no es para subir archivos, es sòlo un formulario. Insertar un correo, leer el campo del correo, actualizar y borrar. Se tiene que conectar a un BD en MS SQL pero me sale el error que comento en el titulo del mensaje.
Gracias
Código PHP:
<html>
<head>
<title> php 5 con sql </title>
</head>
<body bgcolor="#FFFFFF">
<form action="odbc.php" method="post">
<table>
<tr>
<td>
<?
$conn = odbc_connect("10.0.1.0","NOMBRE_BD","user","PASS");
if (isset($_POST['add'])) {
$query = "INSERT INTO emails (email_address_)
values('$_POST[email]');";
odbc_exec($conn,$query);
echo "<h3>Email address added</h3><br><br>";
}
//modificar un registro
if (isset($_POST['update'])) {
$query = "UPDATE emails SET email_address = '$_POST[up_mail]' WHERE email_id=$_POST[up_id];";
odbc_exec($conn,query);
echo "<h3>Email address update</h3><br><br>";
}
// seleccionar
if (isset($_POST['select'])) {
$query = "SELECT * FROM emails WHERE email_id =$_POST[select_id];";
$res = odbc_exec($conn,query);
$rec = odbc_fetch_array($res,0);
// campo oculto
?>
<input type="hidden" name="up_id" value="" <? echo $rec[email_id]; ?>">
<table border = "0" cellspacing = "0" cellpadding = "2" >
<tr valign="top">
<td bgcolor="#003399">
<table width="619" height="11" bgcolor="#ffffff" cellpadding="4" cellspacing = "0">
<tr>
<td widht="150" class="tablecell"> email address </td>
<td width="469" class="tablecell">
<input type="text" name="up_email" value="<? echo $rec[email_address]; ?>" size="60">
</td>
</tr>
<tr>
<td width="150"></td>
<td width="494">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td>
<input type="submit" value="update" name="update">
</td>
<td>
<input type="submit" value="delete" name="delete">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="4" align="center">
<tr>
<td heigth="10"></td>
</tr>
<tr>
<td align="center">
<?
// elimina
if (isset($_POST['delete'])) {
$query = "DELETE FROM emails WHERE email_id=$_POST[up_mail];";
odbc_exec($conn,query);
echo "<h3>Email address delete</h3><br><br>";
}
// recuperar datos
$query = "SELECT * FROM emails ORDER BY email_id;";
$res = odbc_exec($conn,$query);
?>
<select name="select_id">
<?
while (odbc_fetch_row($res)) {
$email_id = odbc_result($res,"email_id");
$email = odbc_result($res,"email");
?>
<option value ="<? echo $email_id; ?>">
<? echo "email id is " . $email_id . ":" . " and email address is " . $email; ?>
</option>
<?
} ?>
</select>
<input type="submit" name="select" value = "select mail" >
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="4" align="center">
<tr>
<td bgcolor="#003399">
<table width="619" cellpadding="4" cellspacing="0" align="center" bgcolor="FFFFFF">
<TR>
<td colspan="2" class="tablecell">
</td>
</tr>
<tr>
<td width="150" height="29"> email address</td>
<td width="494" height="29">
<input type="text" name="email" size="60">
</td>
</tr>
<tr>
<td width="130"></td>
<td width="477">
<input type="submit" value="add New Email Address" name="add">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>