esoteric Posted August 13, 2011 Share Posted August 13, 2011 hi guys, this is probably simple but i couldn't find any posts about it. I have a form that displays some details if the right info has been typed in, if it's wrong info or if the fields have been left blank how can i display some sort of message like ''Invoice data could not be found, please check you details and try again'' At the moment, if you type the details in wrong it the page is just empty. thank you. Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 13, 2011 Share Posted August 13, 2011 what is your current code? Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256843 Share on other sites More sharing options...
esoteric Posted August 13, 2011 Author Share Posted August 13, 2011 It a quite a large page but the start part is ..... $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname) or die (" Cannot find database"); $sql = "SELECT * FROM orderTable WHERE orderNum = '". $order ."' AND custUsername = '". $username ."' AND custPassword = '". $userpass ."'" or die ("Cannot find table"); $query = mysql_query($sql); while ($row = mysql_fetch_array($query)) { ?> <html> <head> .... If the 'custUsername', 'custPassword', or 'orderNum' is wrong i need it to display the error. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256845 Share on other sites More sharing options...
$php_mysql$ Posted August 13, 2011 Share Posted August 13, 2011 create a function and check if it exist in wheresoever you want to check and then call the function in ur error check. is that what u trying to get? Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256846 Share on other sites More sharing options...
esoteric Posted August 13, 2011 Author Share Posted August 13, 2011 That what im trying to do, i just need it to make sure the data the user enters in the form then exists in the sql database, if it doesn't then give an error instead of a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256850 Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 13, 2011 Share Posted August 13, 2011 That what im trying to do, i just need it to make sure the data the user enters in the form then exists in the sql database, if it doesn't then give an error instead of a blank page. do you know how to do it or you are asking us for help? Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256852 Share on other sites More sharing options...
esoteric Posted August 13, 2011 Author Share Posted August 13, 2011 I'm asking for help, i been trying different things i found on the internet but none of them work or are too confusing to understand. Say the order number was typed in wrong then it would display ''Order Number not found'' If the order number exists but the username is wrong; '' Username incorrect'' If the order number exists but the password is wrong; ''Password incorrect'' Thanks for your patience. Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256854 Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 13, 2011 Share Posted August 13, 2011 use if and else to check the data that is being passed. Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256856 Share on other sites More sharing options...
esoteric Posted August 13, 2011 Author Share Posted August 13, 2011 would it be possible to give me an example please? None of my attempts are working, doesn't seem to do anything. Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256865 Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 13, 2011 Share Posted August 13, 2011 ..... $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname) or die (" Cannot find database"); $sql = "SELECT * FROM orderTable WHERE orderNum = '". $order ."' AND custUsername = '". $username ."' AND custPassword = '". $userpass ."'" or die ("Cannot find table"); $query = mysql_query($sql); if(mysql_num_rows($query) < 1) { echo "<h1>Error Status</h1>"; echo "Error!"; } while ($row = mysql_fetch_array($query)) { ?> <html> <head> .... Quote Link to comment https://forums.phpfreaks.com/topic/244698-error-message/#findComment-1256869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.