html - impossible to retrieve the values of my form php mysql


Here is my code:


header('Content-type: text/html; charset=utf-8');

/********Actualisation de la session...**********/


/********Fin actualisation de session...**********/

 if(!isset($_SESSION['membre_admin']))  {
  header ('Location: index.php');

<!DOCTYPE html>
<script language="javascript">

            function confirmeee( identifiant )
                var confirmation = confirm( "Voulez vous vraiment éditercet enregistrement ?" ) ;
        if( confirmation )
          document.location = "edition1.php?idNews="+identifiant ;


and my form


 //récupération de la variable d'URL,
 //qui va nous permettre de savoir quel enregistrement éditer:
 $id = $_GET["idNews"] ;

 //requête SQL:
  $sql = "SELECT *
      FROM news
    WHERE id = ".$id ;
 //echo "$sql" ;    
 //exécution de la requête:
 while($row = mysql_fetch_array( $requete ))

   if($row["text"] != NULL)
      echo '<form method="post" onsubmit="return confirmeee('.$row["id"].')">
      <tr><td>Id article : '.$row["id"].'</label></td></br></br>
      <tr><td><label for="textarea" >Titre :</label></td>

      <td><TEXTAREA name="title" cols="90" >'.$row["title"].'</TEXTAREA></td></tr></br></br>
      <tr><td><label for="title" >Contenu :</label></td>

      <td><TEXTAREA name="text" WRAP=VIRTUAL rows="30" cols="100" >'.$row["text"].'</TEXTAREA></td></tr></br>
      <input type="submit" value="Mise à jour" ></br></br>


and my page edition1.php which it is impossible to retrieve information :


  $id  = $_GET["idNews"] ;

      //récupération du formulaire
      $text = nl2br($text); 

      mysql_query("UPDATE news SET text='$text' , title='$title' WHERE id='".$_GET['idNews']."' ") or die ('Erreur : '.mysql_error());
      echo'L\'article a été modifié<br/><a href="admin.php">Retour</a></br>';


I can t retrieve the informations in edition1.php, when i try my update, this remove my data in "text" and "title".

where is my mistake?




I would change the form tag :

<form method="post" action="edition1.php?idNews='.$row["id"].'">

Then put an onclick event on the button with your JS function :

<input type="submit" value="Mise à jour" onClick="confirmeee()"  />

You don't need the id in the JS script anymore.

Then finally call


instead of

document.location = "edition1.php?idNews="+identifiant ;

People are also looking for solutions to the problem: wordpress - How to get the current project name in php code?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.