<?php
$retrive=mysql_query("SELECT * FROM oes.questions;");
$questions=mysql_fetch_array($retrive);
?>
<form action="delete.php" method="post">
<input type="checkbox" name="del" value=<?php $questions["q_no"] ?> /><?php echo $questions["q_no"]; ?>
<input type="submit" value="submit"/>
<?php
if(isset($_POST["del"]))
{
echo $_POST["del"];
}
?>
I want to use delete ($_POST["del"]) function but for debugging I used echo and found that it prints '/' .
value='<?php echo $questions["q_no"]; ?>'
You didn't echo the value of the $questions
index.
EDIT: To help prevent XSS:
Make sure you set the header correctly:
header('Content-type: text/html; charset=utf-8');
value="<?php echo htmlspecialchars($questions['q_no'], ENT_QUOTES, 'UTF-8'); ?>"
First thing that pops out is that you're not quoting the value attribute:
value=<?php $questions["q_no"] ?> /
You're also not escaping any quotes from $questions["q_no"]
. As value needs to be wrapped in quotes, and adding additional quotes will only cause value to get set to the wrong value, its not surprising your getting a strange value posted back to the server (maybe even part of the rest of the form HTML, including the /).
As mentioned by, You need echo the value and also qoute (') issue. Try this
<input type="checkbox" name="del" value='<?php echo $questions["q_no"]; ?>' /><?php echo $questions["q_no"]; ?>
OR
<input type="checkbox" name="del" value="<?php echo $questions['q_no']; ?>" /><?php echo $questions["q_no"]; ?>
<input type="checkbox" name="del" value=<?php $questions["q_no"] ?> />
You aren't echoing the question, so your HTML is rendered as:
<input type="checkbox" name="del" value= />
Which is therefore parsed as:
<input type="checkbox" name="del" value=" /">
You need to quote your attributes, and also make sure you tell PHP to echo someting.
<input type="checkbox" name="del" value="<?php echo $questions["q_no"] ?>" />