i am trying to pass a php value get from page1.php to ra.php. user clicks on something in page1.php and a unique id is being passed to ra. php via url that i extract using $_GET but when i click on submit button in ra. php it says
PHP Notice: Undefined variable: c_id in "filepath" on line 22 the variable used in input field for value
The code of ra.php is as following:
<?php
require 'config.php';
$c_id = '';
$cmt_id;
if(isset($_GET['cid']))
{
$c_id= $_GET['cid'];
if(isset($_POST['submit']))
{
$cmt_id = ($_POST['com_id']);
$sql = "INSERT INTO ra(comment_id)
VALUES('$cmt_id')";
$success = $conn->exec($sql);
}
}
$conn = null;
?>
<!DOCTYPE html>
<html lang="en">
<body>
<form action="ra.php" method="post">
<input type="text" name="com_id" value="<?php echo $c_id;?>">
<button type="submit" name="submit">Submit</button>
</form>
</body>
</html>
it shows the value passed by page1.php via url in inpur field. but when i click on submit then instead of inserting the data into database it displays the error notice for c_id in input filed line.
I have tested the if(isset($_GET['cid'])) and its true it gets the value from page1.php. but some how does not pass the value to the database.