Inserting ID through PHP and MySQL -


i trying pass id 1 page another. getting id in other page , trying insert id in different table. consider have 1 table 'question' , taking question id table , passing page. trying store id in table 'answer' in next page. here codes-

the first page-

<?php                  require('connect_db.php');                 $strsql = "select * question";                 $rs = mysqli_query($conn,$strsql);                 while($row = mysqli_fetch_array($rs,mysqli_assoc)) {                     echo "<a href='addanswer.php?isedit=1&id=" .$row['qu_title']. "'><h3 style='font-family: georgia;margin-left: 3.8%'>".$row['qu_title']."</h3></a>";                    echo "<h5 style='font-family: georgia;margin-left: 3.8%'>".$row['qu_text']."</h5>";                    echo "<hr>";                   }                  mysqli_close($conn);              ?> 

the second page-

<?php    session_start();    require('connect_db.php');    if (isset($_session['email']) , $_session['loggedin'] == "true") {    global $id; $id = ($_get['id']); //echo $id; if (isset($_post['answer']))  {     $answer=$_post['answer'];     mysqli_query($conn,"insert answer(qu_id,ans_text)values      ('$id','$answer')");     header("location:main.php?msg=success");     mysqli_close($conn);    }  }    else {      header("location:login.php?msg=try");   } ?> 

but there seems problem in inserting id. can figure out problem?

you passing value first page second page method. in second page you're using $_post['id'] insert value. can use $_get['id'] or $_request['id']


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -