Location: PHPKode > scripts > Tabs Links SQL > tabs-links-sql/upcad.php
<?php

include "header.php";
include ("config.php");

$upcad = $_POST["upcad"];

switch ($upcad) {

// Insertion of links in Mysql
case ($button_inserir):

$nome = $_POST["nome"];
$descricao = $_POST["descricao"];
$link = $_POST["link"];
$data = date("Y-m-d : H-i-s");

$inserir = "insert into $tabelabd (data,nome,descricao,link) values ('$data','$nome','$descricao','$link')";
mysql_query ($inserir) or die ("Problem in the insertion");

// Writes the inserted link and redirects
echo "<br><font face='verdana,arial' size='2'>Link <b>$nome</b> inserted successful</font><br>";
echo "<script type=\"text/javascript\">
function Redirecionar() {location.href = \"$link_admin\";}
window.setTimeout(\"Redirecionar()\", 4000); </script>";
break;

// Update of links in Mysql
case ($button_atualizar):

$id = $_POST["id"];
$nome = $_POST["nome"];
$descricao = $_POST["descricao"];
$link = $_POST["link"];

$consulta = "select * from $tabelabd where id=$id";
$resultado = mysql_query($consulta) or die("Cannot to delete");
$linha = mysql_fetch_array($resultado);

$nomeatualizado = $linha["nome"];

$update ="update $tabelabd set nome='$nome', descricao='$descricao', link='$link' where id=$id";
$atualizar = mysql_query($update) or die ("Cannot to update. Don't use special chars");

// Writes the updated link e redirects
echo "<font face='verdana,arial' size='2'>Link <b>$nomeatualizado</b> atualizado<br><br>Redirecting...</font><br>";
echo "<script type=\"text/javascript\">
function Redirecionar() {location.href = \"$link_admin\";}
window.setTimeout(\"Redirecionar()\", 3000); </script>";
break;
}
mysql_close($conexao);
include "footer.php";

?>
Return current item: Tabs Links SQL