Posted: Wed Oct 04, 2006 3:06 pm
poopoo kaka... you have to declare the $result variable and assign it a value before it will be useful in any way...
Code: Select all
<?php
include "m_config.php";
if(isset($_POST['action']) && $_POST['action'] == "add")
{
$name = $_POST['name'];
$lname = $_POST['lname'];
$choice = $_POST['choice'];
$date = time();
$ip = GetHostByName($_SERVER['REMOTE_ADDR']);
if(!$name || !$lname)
{
$result = "Please fill all the required fields";
}
else
{
$query = mysql_query("insert into m_record (name,lname,yesno,date,ip) values('$name','$lname','$choice','$date', '$ip')");
if(!$query)
{
$result = "An error has occured";
}
else
{
$result = "Thanks...";
}
}
}
function read()
{
global $total;
$total = 0;
$query = mysql_query("select * FROM m_record where yesno='yes'");
while($array = mysql_fetch_array($query))
{
$total += 1;
}
return $total;
}
echo "<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form name=\"decision\" method=\"post\" action=\"http://127.0.0.1/web/file.php\">
<input type=\"hidden\" name=\"action\" value=\"add\">
<input name=\"name\" type=\"text\">
<input name=\"lname\" type=\"text\">
<br />
<label title=\"choice\" >
yes <input name=\"choice\" type=\"radio\" value=\"yes\" checked>
No <input name=\"choice\" type=\"radio\" value=\"no\"></label>
<input type=\"submit\" value=\"submit\" />
</form> <br /> $result
".read()."
</body>
</html>";
?>