Quantcast
Channel: Últimos conteúdos
Viewing all articles
Browse latest Browse all 14190

UPDATE

$
0
0

Olá pessoal, estou com problema pra fazer um UPDATE com php.


<p> <?php  include("config/connect.php"); ?>  </p>



<?php

//Lista de variaveis
$nome=$_POST['Nome'];
$sobrenome=$_POST['Sobrenome'];
$email=$_POST['Email'];
$c_email=$_POST['C_email'];
$telefone=$_POST['Telefone'];
$level=$_POST['Level'];
$senha=$_POST['Senha'];
$c_senha=$_POST['C_senha'];

//Verifica 'se' o botão foi clicado.


 if(isset($_POST["botao_reg"])){
$gravando = mysql_query("INSERT INTO profile_account (profile_name, profile_lastname,profile_email,profile_phone,profile_level,profile_pass) VALUES ('$nome', '$sobrenome','$email','$telefone','$level','$senha')");
 }

 


?>



<p>Cadastro de usuários </p>

<!-- input with placeholder -->
<form method="post"   data-role="validator" 
data-show-required-state="false" 
data-hint-mode="line" 
data-hint-background="bg-red" 
data-hint-color="fg-white" 
data-hide-error="5000">

<div class="input-control text">
    <input name="Nome"type="text" data-validate-func="required" placeholder="Nome" data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control text">
    <input name="Sobrenome"type="text" data-validate-func="required" placeholder="Sobrenome" data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control text">
    <input name="Email"type="email" data-validate-func="required" placeholder="Email" data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control text">
    <input name="C_email"type="email" data-validate-func="required" placeholder="Confirme E-mail" data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control text">
    <input name="Telefone"type="tel" data-validate-func="required" placeholder="Telefone" data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control text">
    <input name="Senha" type="password" data-validate-func="required" placeholder="Senha" data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control text">
    <input name="C_senha"type="password" data-validate-func="required" placeholder="Confirme senha." data-validate-hint="Não pode ser vazio."> 
</div>
<div class="input-control select">
    <select name="Level">
        <option value="1">Level-1</option>
        <option value="2">Level-2</option>
        <option value="3">Level-3</option>
    </select>
</div>
<p>
<input class="button success"name="botao_reg"type="submit" value="Registrar">
</p>
</form>
<hr>



<?php 

 
    $sql = ("SELECT * FROM profile_account");
    $resultado =  mysql_query($sql);
while ($linha= mysql_fetch_assoc($resultado)) {
$select .= "
				   
					<tr>
						<td width='5' >
							{$linha["profile_id"]}</td>
						<td width='33%'>
						 <input name='Nome1'type='text'size='15' value='	{$linha["profile_name"]}' > </td>
						<td width='33%'>
							 <input name='Sobrenome'type='text'size='15' value='	{$linha["profile_lastname"]}'></td>
							<td width='33%'>
							 <input name='Email'type='text'size='15' value='	{$linha["profile_email"]}'></td>
							<td width='33%'>
							 <input name='Telefone'type='text' size='15'value='	{$linha["profile_phone"]}'></td>
							<td width='5%'>
							 <input name='level'type='text'size='2' value='	{$linha["profile_level"]}'></td>
							<td width='33%'>
							
							<a href='?p=profile_new&id_up={$linha["profile_id"]}'>Atualize</a></td>
						<td width='33%'>
							<a href='?p=profile_new&id_down={$linha["profile_id"]}'>Delete</a></td>
					</tr>
				 
            
			";
			
			

 
}
?>
<?php echo "

 
<table class='table striped hovered cell-hovered border bordered'>  
    <tr>
        <td>ID</td>
        <td>Nome</td>
        <td>Sobrenome</td>
        <td>E-mail</td>
        <td>Telefone</td>
        <td>Level</td>
        <td>Edite</td>
        <td>Delete</td>
    </tr> 
	 
	
	"; ?>
<?php echo $select ?>
<?php echo" </table> "; ?>


<?php
    if($_GET['id_down'] != ""){
    $userID1 = $_GET['id_down'];
    $sql1 = "DELETE FROM profile_account WHERE profile_id='".$userID1."'";
    $query1  = mysql_query($sql1);
	}
?>

<?php
    if($_GET['id_up'] != ""){
    $userID1 = $_GET['id_up'];
      $sql1 = "UPDATE profile_account SET profile_name='$nome' WHERE profile_id='".$userID1."'";serID1."'";
    $query1  = mysql_query($sql1);
	}
?>




No casso... sempre que eu cliko em atualizar ele apaga o registro e nao salva nada...

segue link com exemplo online

 

http://work-web.ddns.net/administration.php?p=profile_new


Viewing all articles
Browse latest Browse all 14190