I have a problem, submit button is not working on index.php and if I copied into another page it works fine..

here is the complete code..

<?php session_start();
if (!isset($_SESSION['username']))
{
header('Location: login.php');
}
?>
<!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>
<script type="text/javascript">
function delP(num)
{
	var cn=confirm("Do you really want to delete this Job.");
	if(cn==true)
	{
		window.location="delete-record.php?num="+num;
	}
}

function open_win(num)
{
window.open("icard.php?num="+num,"_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=358, height=215");
}

</script>

<style type="text/css">
table, th
{
border:1px thin #666666;
font-family:Verdana;
font-size:12px;
vertical-align:top;
}
th
{
background-color:#666666;
color:white;
}
a {
 text-decoration:none;
 color:#FF9999;
 font-size:small;
}

a:hover{
 text-decoration:underline;
 color:black;
 

}
</style>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Jai Sakhi Baba : Home</title>
</head>

<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table style="vertical-align:top" border="1" width="800px" align="center" cellspacing="0" cellpadding="0">
<tr style="color:white" bgcolor="#666666">
   <td align="center"><a href="index.php">Home</a></td>  
   <td align="center"><a href="add-user.php">Add records</a></td>
   <td align="center"><a href="print.php">Print reports</a></td>
   <td align="center"><a href="download.php">Download records</a></td>
   <td align="center"><a href="user-form.php">Add User</a></td>
   <td align="center"><a href="user-list.php">User List</a></td>
</tr>
<tr>
<td style="background-color:#666666;" align="center"><a href="city-wise.php">City wise result</a></td>
  <td align="center" colspan="4"><strong>Search by:</strong>&nbsp;&nbsp;&nbsp;<select>
      <option>Name</option>
      <option>Phone number</option>
      <option>Father </option>
      <option>city</option>
  </select>
  &nbsp;&nbsp;&nbsp;
  <input type="text" name="keyword"/>&nbsp;&nbsp;&nbsp;
  <input type="hidden" name="searching" value="yes" />
  <input type="submit" name="submit" value="Submit">
  </td>
  
  <td align="center"><div class="style1"><b>Welcome :&nbsp;</b> <?php echo $_SESSION['username']; ?>&nbsp;&nbsp;<br/><a href="logout.php" >Logout</a></div></td>

</tr>
<tr>
<th style="height: 20px">क्रम संख्या</th>
<th style="height: 20px">जन्म तिथि</th>
<th style="height: 20px">नाम</th>
<th style="height: 20px">फ़ोन नंबर</th>
<th style="height: 20px">नामदान तिथि </th>
<th style="height: 20px">I-card</th>
</tr>
<?php
include('ps_pagination.php');
include('db_hindi.php');
?>
<tr>
<?php
$gender_status=$_POST['gender'];
$keyword=$_POST['keyword'];
	if(isset($_POST['submit']))
		{
		//echo "in search";
		$sql ="SELECT * FROM tbl_hindi WHERE name LIKE '%$keyword%' or mobile LIKE '%$keyword%' or father LIKE '%$keyword%' or city LIKE '%$keyword%' or state LIKE '%$keyword%'";
		echo 		$sql;
		}
	else
		{
		//echo "outside";
		$sql ="SELECT * FROM `tbl_hindi` order by gender desc ,namdan_date desc";
		}
/* if(isset($_POST['search']))
{
echo "in search";
$sql ="SELECT * FROM tbl_hindi WHERE name LIKE '%$keyword%' or mobile LIKE '%$keyword%' or father LIKE '%$keyword%' or city LIKE '%$keyword%' or state LIKE '%$keyword%'";
}
else
{
echo "outside";
$sql ="SELECT * FROM `tbl_hindi` order by gender desc ,namdan_date desc";
}*/
mysql_query("SET NAMES utf8"); 
$pager = new PS_Pagination($conn, $sql, 8, 3, "param1=valu1&param2=value2");
$pager->setDebug(true);
$rs = $pager->paginate();
if(!$rs) die(mysql_error());
while($row = mysql_fetch_assoc($rs)) 
  {
  
?>
<td><?php echo $row[num];?></td>
<td><?php  $str_pos=strpos($row[dob],"00");
          $str_check=strpos($row[dob],"0000");
  if($str_pos=='5')
  {   
  echo $dob1=substr($row[dob],0,4);
  }
  else
  {
  echo date("d-M-Y", strtotime($row[dob]));
  }
?></td>
<td><?php echo $row[name]." <br />"."$row[relation] "."$row[abbr] ". "$row[father]"."<br/ >"."$row[address] "."$row[city]".", "."$row[state]" ?></td>
<td><?php echo $row[mobile]?></td>
<td><?php 
$str_pos1=strpos($row[namdan_date],"00");
$str_check1=strpos($row[namdan_date],"0000");

  if($str_pos1=='5')
  {   
  echo $dob_nam=substr($row[namdan_date],0,4);
  }
  elseif($str_check1=='0')
  {
  echo date("d-M-Y", strtotime($row[namdan_date]));

  }
  else
  {
  echo date("d-M-Y", strtotime($row[namdan_date]));

  
  }

?></td>
 <?php 
	echo "<td align='center'>" ."<a href=\"update_record.php?num=$row[num] \"><img src=\"images/edit1.jpg\" border=\"0\" alt=\"edit\" title=\"edit\"></a>\n"."<a href=\"#\"onclick=\"delP($row[num])\"><img src=\"images/del.jpg\" border=\"0\" alt=\"Delete\" title=\"Delete\"></a>\n"."<a href=\"# \" onclick=\" open_win($row[num])\"><img src=\"images/view1.jpg\" border=\"0\" alt=\"View\" title=\"View\"></a>\n". "</td>";?>
</tr>

<?php }

?>
<tr>
<td style="background:#666666" align="center"><a href="import_file.php">Import file</a></td>
<td colspan="4" align="center">
<?php

echo $pager->renderFirst();
echo $pager->renderPrev();
echo $pager->renderNav('<span>', '</span>');
echo $pager->renderLast();

?>
</td>
<td style="background-color:#666666; color:white"><font color="#FF9999">Total records:</font><?php  $count=mysql_query("select * from tbl_hindi");
$num_rows = mysql_num_rows($count);
echo $num_rows;   
 ?></td>
</tr>
<tr>
<td colspan="6" style="height: 20px"><div style="color:red" align="center"><?php echo $_REQUEST['msg'];?></div></td>
</tr>
<tr>
	<td><input type="submit" name="button" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
	if($_POST['button'])
		echo "button";
?>

Recommended Answers

All 4 Replies

Post index.php you've problem.

Post index.php you've problem.

This is index.php.when i use that code on index page submit button is not working,while on other pages its working fine.

The name of the two submit buttons are the same.
Edit first button name as submit1.Also edit
isset($_POST) as isset($_POST)

Only that much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.