tomfmason Posted July 21, 2006 Share Posted July 21, 2006 I am attempting to create a mysql chat script and am running into a little trouble with the login script.The problem that I am having is that the errors are being processed before the user has a chance to enter the required information. Here is a relivant section of the script.[code=php:0]<?phpinclude('includes/db.php');if (isset($submit)) { array_pop($_POST); if ( get_magic_quotes_gpc() ) { $_POST= array_map('stripslashes', $_POST); } $first_name = mysql_real_escape_string(trim($_POST['first_name'])); $last_name = mysql_real_escape_string(trim($_POST['last_name'])); $email = mysql_real_escape_string(trim($_POST['email'])); $status = "waiting"; if ((!$first_name) || (!$last_name) || (!$email) || (!$deparment)) { $message = "error"; if (!$first_name) { $error = "first_name"; } if (!last_name) { $error = "last_name"; } if (!$email) { $error = "email"; } if (!$department) { $error = "department"; } exit(); } $sql = mysql_query("INSERT INTO chat (first_name, last_name, email, department, status, chat_date, chat_time) VALUES ('$first_name', '$last_name', '$email', '$department', '$status', now(), now())") or die(mysql_error()); if (!$sql) { $message = "sql"; } session_start(); $session_sql = "SELECT chat_id FROM chat WHERE email ='$email' AND status ='waiting'"; $get_session = mysql_query($session_sql) or die(mysql_error()); if (!$get_session) { $message = "session"; } $_SESSION['chat_id'] = "$get_session"; header("Location: http://www.owpt.biz/chat.php"); } ?>[/code]Should I use [code=php:0]<?phpif (isset($submit)) { if (empty($variable)) { $error = "whatever" } //the rest of my error checking}[/code]Any suggestions would be great. Quote Link to comment https://forums.phpfreaks.com/topic/15220-isset-question/ Share on other sites More sharing options...
hvle Posted July 21, 2006 Share Posted July 21, 2006 you should know the different between isset and empty.case1:<?php $var = null; isset($var) will return true here; empty($var) will return true here;?>case 2:<?php isset($var) will return false here; empty($var) will return true here;?>case 3:<?php $var = 'something'; isset($var) will return true here; empty($var) will return false here;?> Quote Link to comment https://forums.phpfreaks.com/topic/15220-isset-question/#findComment-61511 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.