Geting problem with is_integer function
Posted: Sat Jan 06, 2007 2:55 am
Geting problem with is_integer function . am trying to check weather the a variable pin is integer or not ,if it's not integer display message , but in the both case weather the variable is integer or not message it display on the screen
Code: Select all
<?php
ob_start();
/*
session_start();
if(!isset($_SESSION['sessref']))
{
session_destroy();
header("location:admincp.php");
exit;
} */
?>
<html>
<head>
<link href = "includes/admin.css" type = "text/css" rel = "stylesheet">
<title>
Add Student
</title>
</head>
<body valign="top">
<img src="images/l.jpg" width="1000" height="150" alt="" border=0>
<br/>
<br/>
<?php
if(isset($_POST['submit']))
{
if($_POST['name'] && $_POST['pws'] && $_FILES['image'] && $_POST['e_mail'] && $_POST['pin'])
{
// here what am talking about ****Start**********
if(!is_integer($_POST['pin']))
{
echo "<table width=\"600\" align=\"center\" border=\"0\">";
echo "<tr>\n";
echo "<td><font color=\"red\">*</font>Please Enter Pin Code As Number Not String</td><br/><br/>";
echo "<tr>\n";
echo "</table>\n";
exit();
}
//*********************End*******************
include('includes/config.php');
$spath = $_FILES['image']['tmp_name'];
$dpath = "images/".$_FILES['image']['name'];
move_uploaded_file($spath,$dpath);
$insert = "insert into tbl_student values('','".$_POST['name']."','".$_POST['pws']."','".$dpath."','".$_POST['e_mail']."','".$_POST['pin']."')";
$result = mysql_query($insert) or die(mysql_error());
if(!$result)
{
echo "Insert not successful!";
exit;
}
header("location:student_list.php");
exit;
}
else if($_POST['name'] || $_POST['pws'] || $_FILES['image'] || $_POST['e_mail'] || $_POST['pin'])
{
echo "<table width=\"600\" align=\"center\" border=\"0\">";
echo "<tr align=\"center\">\n";
echo "<td><font color=\"red\">*</font>Please Fill all field</td><br/><br/>";
echo "<tr>\n";
echo "</table>\n";
}
}
ob_end_flush();
?>
<table width="600" align="center" border="1">
<form name="insert" method="post" action="" enctype="multipart/form-data">
<tr>
<th colspan="2" align="center">Add Student</th>
</tr>
<tr>
<td align="right">Name:</td><td align="left"><input type="text" name="name"/></td>
</tr>
<tr>
<td align="right">Password:</td><td align="left"><input type="password" name="pws"/></td>
</tr>
<tr>
<td align="right">image:</td><td align="left"><input type="file" name="image"/></td>
</tr>
<tr>
<td align="right">E_mail:</td><td align ="left"><input type="text" name="e_mail"/></td>
</tr>
<tr>
<td align="right">Pin_code:</td><td align="left"><input type="text" name="pin"/></td>
</tr>
<tr>
<td align="right"><input type="submit" name="submit" value="Add"/></td>
<td align="left"><input type="reset" name="reset" value="Clear"/></td>
</tr>
</form>
</table>
</body>
</html>