Page 1 of 1

Blank fields detection

Posted: Thu Dec 04, 2008 8:42 am
by olidenia
having some problems with this code:

Code: Select all

<?php
 
$con = mysql_connect("$hostName","$dbName","$dbUserPw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("$dbName", $con);
 
{
//This makes sure they did not leave any fields blank
if (!$_POST['firstname']) 
die ('No one here by that name!!');
}
 
$result = mysql_query ("SELECT * FROM Sandbox
WHERE FirstName='$_POST[firstname]'");
 
 
 
while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br />";
  }
?>
I can't get this part to work, I have it on another file and it works fine.

Code: Select all

{
//This makes sure they did not leave any fields blank
if (!$_POST['firstname']) 
die ('No one here by that name!!');
}
Any help?
Thank you

Re: Blank fields detection

Posted: Thu Dec 04, 2008 8:48 am
by olidenia
Sorry, excuse me, this piece of code works perfectly, my fault, I whas expecting it to do something else, hehe.

The beginings of PHP can make you a bit :crazy: