- Impact
- 4
hi,
Just a simple bit of code but its a bit mucked up.
Im just getting a blank page - no errors.
Can anyone help?
cheers,
-ed
Just a simple bit of code but its a bit mucked up.
Im just getting a blank page - no errors.
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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body bgcolor="#00FF00">
<?php
$username="root";
$password="********";
$database="msn";
$firstn=$_POST['first'];
$lastn=$_POST['last'];
$msn=$_POST['msn'];
$class=$_POST['class'];
if($do == "insert"{
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO `addys` (`firstn`, `lastn`, `msn`, `class`) VALUES ('$firstn', '$lastn', '$email', '$class')";
$result=mysql_query($query);
if(!$result){
echo"error, data nt submitted";
}
mysql_close();
}elseif($do == "form"){
echo"<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td><form id='form1' name='form1' method='post' action='index.php?do=insert'>
<div align='right'>: first name : </div>
<label>
<div align='right'>
<input type='text' name='firstn' />
</div>
</label>
<div align='right'><br />
: last name : </div>
<label>
<div align='right'>
<input type='text' name='lastn' />
</div>
</label>
<div align='right'><br />
: msn address : </div>
<label>
<div align='right'>
<input type='text' name='msn' />
</div>
</label>
<div align='right'><br />
: class : </div>
<label>
<div align='right'>
<input type='text' name='class' />
</div>
</label>
<p align='right'>
<label>
<input type='submit' name='Submit' value='Submit' />
</label>
</p>
</form></td>
</tr>
</table>";
}else{
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM msn";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$firstname=mysql_result($result,$i,"first");
$lastname=mysql_result($result,$i,"last");
$email=mysql_result($result,$i,"msn");
$classname=mysql_result($result,$i,"class");
echo "<b>$firstname $lastname</b><br>addy: $msn<br>class: $classname<br><hr><br>";
$i++;
}
}
?></body>
</html>
Can anyone help?
cheers,
-ed








