0
Good evening, I have a code where I do an Insert into,but this returning me error, and I am unable to solve, in the same field is printed in the database, page and content. The page is registered but the content causes error; and the error is: Notice: Undefined index: content my code:
$pagina_editar = $_POST['pagina'];
$content_editar = $_POST['content'];
if(isset($_POST['cadastrar']) && $_POST['cadastrar'] == 'envia_form'){
$cadatrar_pagina = mysqli_query($conexao,"INSERT INTO lp_page (pagina, content) VALUES ('$pagina_editar', '$content_editar')")or die(mysqli_error($conexao));
}
if(isset($_POST['editar_post']) && $_POST['editar_post'] == 'envia_form'){
$atualiza_pagina = mysqli_query($conexao,"UPDATE lp_page SET content='$content_editar' WHERE pagina = '$pagina_editar'") or die (mysqli_error($conexao));
}
$pagina_de_edicao = $_POST['pagina'];
$pega_pagina = mysqli_query($conexao,"SELECT id, pagina, content FROM lp_page WHERE pagina = '$pagina_de_edicao'")or die(mysqli_error($conexao));
if(@mysqli_num_rows($pega_pagina) <= '0'){
?>
<form action="" method="post" enctype="multipart/form-data" name="cadastrar_pagina">
<input type="hidden" name="pagina" value="<?php echo $pagina_de_edicao;?>" />
<textarea name="content" rows="30" cols=""></textarea>
<input type="hidden" name="cadastrar" value="envia_form" />
<input type="submit" value="Cadastrar" name="Cadastrar" class="cadastro_btn" />
</form>
<?php
}else{
while($res_pagina = mysqli_fetch_array($pega_pagina)){
$id = $res_pagina[0];
$pagina = $res_pagina[1];
$content = $res_pagina[2];
?>
<form action="" method="post" enctype="multipart/form-data" name="edita_pagina">
<input type="hidden" name="pagina" value="<?php echo $pagina_de_edicao;?>"/>
<textarea name="content" cols="" rows="30"> <?php echo $content; ?></textarea>
<input type="hidden" name="editar_post" value="envia_form" />
<input name="Editar" type="submit" value="Editar" class="cadastro_btn" />
</form>
<?php
}
}
?>
the error is happening on the line: $content_edit = $_POST['content']; can anyone help me? Thanks
Why does the form have
multiplart/form-data
? The<form ...>
and</form>
must be outside the looping. Try these changes, and if possible also add the codePHP
.– Edilson
http://answall.com/questions/how-saber-se-form-%C3%A9-sent/89142#89142
– Daniel Omine
this other one also: http://answall.com/questions/89960/como-validar-cada-tipo-date-receivedde-um-formul%C3%A1rio/90026#90026
– Daniel Omine