Jump to content

Simple post not working (bug).


Go to solution Solved by cyberRobot,

Recommended Posts

hi,
I am using the below code and want a simple print on submit event, but it is not giving any result.
Please have a look and suggest.


<?php
if(isset($_POST['submit'])){
$slno=$_POST['slno'];
echo "hello"." ".$slno;// this is to print.
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body bgcolor="#FF0000">
<form id="registration" name="registration" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<?php
require_once("proconfig.php");
$query_for_result=mysqli_query($con,"SELECT * FROM album ORDER BY id ASC");
$num=mysqli_num_rows($query_for_result);
mysqli_close($con);

?>
<table >
<tr>
<td>Sl.No..</td>
<td >Item</td>
<td >Paper</td>
<td >Finish</td>
<td >Price</td>
<td >Vat</td>
<td >Total Amount</td>

</tr>

<?php

$i=0;

while($row = mysqli_fetch_assoc($query_for_result)) 
{
$f1=$row['id'];
$f2=$row['album_name'];
$f3=$row['paper_used'];
$f4=$row['finishing'];
$f5=$row['price'];
$f6=$row['vat'];
$f7=$row['total_amt'];

$id=$i+1;
//echo $id;
?>
<tr>
<td><input id="slno" name="slno[]" value="<?php echo $f1; ?>" type="text" style="width:20px;"/></td>
<td><input id="album_name" name="album_name[]" value="<?php echo $f2; ?>" type="text" style="width:150px;"/></td>
<td><input id="paper_used" name="paper_used[]" type="text" value="<?php echo $f3; ?>" style="width:85px;"/></td>
<td><input id="finishing" name="finishing[]" value="<?php echo $f4; ?>" type="text" style="width:90px;"/></td>
<td><input id="price" name="price[]" value="<?php echo $f5; ?>" type="text" style="width:25px;"/></td>
<td><input id="vat" name="vat[]" type="text" value="<?php echo $f6; ?>" style="width:35px;"/></td>
<td><input id="total_amt" name="total_amt[]" value="<?php echo $f7; ?>" type="text" style="width:50px;"/></td>

</tr>
<?php
$i++;

}

?>
<tr>
<td colspan="7" ><input name="save" value="Save" id="save" type="submit" style="width:83px;" /></td>

</tr> 
</table>
</form>

</body>
</html>

thanks

Edited by rajeshkr
Link to comment
https://forums.phpfreaks.com/topic/287121-simple-post-not-working-bug/
Share on other sites

  • Solution

Your submit button is named "save"...try the following:

<?php
if(isset($_POST['save'])){
     $slno=$_POST['slno'];
     echo "hello"." ".$slno;// this is to print.
}
?>

Also, I would recommend checking out the following article with regard to using PHP_SELF:

http://seancoates.com/blogs/xss-woes

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.