ok i have this login script <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="select.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Poster </strong></td> </tr> <tr> <td width="78">name</td> <td width="6">:</td> <td width="294"><input name="myname" type="text" id="myname"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Poster"></td> </tr> </table> PHP: you enter your name and goes to next page which shows records of that name but i need an error page if name is not in database <?php // Connects to your Database $dbh=mysql_connect("localhost", "cavcd", "57") or die('I cannot connect to database because: ' .mysql_error()) ; mysql_select_db("pets"); $myname=$_POST['myname']; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM register where name='$myname'") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.mouth.com/images/".$info['pname'] ." alt=\"Image\" align=\"center\" width=\"150px\" height=\"150px\" hspace=\"10px\" vspace=\"8px\"> <br>"; Echo "<b>State:</b> ".$info['state'] . " <br>"; Echo "<b>Type:</b> ".$info['type'] . " <br>"; Echo "<b>Area:</b> ".$info['area'] . " <br>"; Echo "<b>Description:</b> ".$info['desc'] . " <br>"; Echo "<b>If Seen Please Tel:</b> ".$info['tel'] . " <br>"; } mysql_close(); ?> PHP: cheers Doug
why not try something like <?php // Connects to your Database $dbh=mysql_connect("localhost", "cavcd", "57") or die('I cannot connect to database because: ' .mysql_error()) ; mysql_select_db("pets");$myname=$_POST['myname']; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM register where name='$myname'") or die(mysql_error()); $countrows = mysql_num_rows($data); if($countrows == 0){ ERROR STUFF HERE } ELSE { //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.mouth.com/images/".$info['pname'] ." alt=\"Image\" align=\"center\" width=\"150px\" height=\"150px\" hspace=\"10px\" vspace=\"8px\"> <br>"; Echo "<b>State:</b> ".$info['state'] . " <br>"; Echo "<b>Type:</b> ".$info['type'] . " <br>"; Echo "<b>Area:</b> ".$info['area'] . " <br>"; Echo "<b>Description:</b> ".$info['desc'] . " <br>"; Echo "<b>If Seen Please Tel:</b> ".$info['tel'] . " <br>";} mysql_close();?> } PHP: hope it helps. If you need some more help, feel free to PM me
<?php $data = mysql_query("SELECT * FROM register where name='$myname'"); if ( mysql_num_rows($data) == 0 ) { header("Location: error_page.php"); exit(); } else { // Continue } ?> PHP: