Email Blade Got Undefined variable: when using Laravel queue - php

I tried to queue successful email whenever someone place new order on my website. I used event and listener to accomplish this. Below is my code for sending the email on listener file:
NewOrderListener.php
public function handle($event)
{
try {
dump('new order registered (listernerrr)');
$email = $event->order['email'];
Mail::send('email.order_mail_customer', $event->order, function($message) use($email)
{
dump($email);
$sub_data = (Lang::has(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS')) ? trans(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS') : trans($this->FRONT_LANGUAGE.'.FRONT_ORDER_SUCCSESS');
dump($sub_data);
$message->to('googleadmin#gmail.com')->subject($sub_data);
dump('email sent');
});
} catch (\Exception $e) {
dump($e->getMessage());
}
}
email.order_mail_customer.blade.php file :
<html>
<body style="margin: 0; padding: 0;">
#if(count($order_details) > 0)
<table cellpadding="0" cellspacing="0" width="600" align="center" style="border:1px solid #ddd;">
<tr>
<td style="border-top: 5px solid #f7d501;">
<table style="padding:10px;width:100%;">
<tr>
<td align="center">
#php $path = url('').'/public/images/noimage/default_image_logo.jpg'; #endphp
#if(count($logo_settings_details) > 0)
#php
foreach($logo_settings_details as $logo_set_val){ }
#endphp
#if($logo_set_val->admin_logo != '')
#php $filename = public_path('images/logo/').$logo_set_val->admin_logo; #endphp
#if(file_exists($filename))
#php $path = url('').'/public/images/logo/'.$logo_set_val->admin_logo; #endphp
#endif
#endif
#endif
<img src="{{$path}}" alt="#lang(Session::get('front_lang_file').'.ADMIN_LOGO')" class="img-responsive logo" width="100">
</td>
</tr>
</table>
</td>
</tr>
Exception message:
Undefined variable: logo_settings_details in email.order_mail_customer.blade.php
Above code running OK when I set queue driver=sync and without queue.
But I got undefined property/variable on order_mail_customer.blade.php when I'm using queue by setting up driver=database and implements ShouldQueue to NewOrderListener file. Hopefully someone could help me to solve this problem. Thanks in advance.

Nevermind, I've found the issue, this variable couldn't be call because of this variable is static variable, it get destroy before the queue got running.

Related

Locale Get Ignored When Sending Mail with Queue

I'm looking for an answer. Laravel Framework 5.5.44
and I have a queue that will send an email whenever someone place new order on my website. I used event and listener to accomplish this. My queue successfully sent the email but my locale code does not working. Below is my code :
NewOrderListener.php
public function handle($event)
{
try {
dump('new order registered (listernerrr)');
// dump($event->order);
$email = $event->order['email'];
// $logo_settings_details = Settings::get_logo_settings_details();
// // dump($logo_settings_details);
// $event->order->prepend('logo_settings_details', DB::table('gr_logo_settings')->get());
// array_push($event->order, DB::table('gr_logo_settings')->get());
$event->order['logo_settings_details'] = DB::table('gr_logo_settings')->get();
// $data = [
// 'logo_settings_details' => DB::table('gr_logo_settings')->get(),
// ];
// dd($data);
$get_images = DB::table('gr_no_images')->select('banner_image','restaurant_store_image','restaurant_item_image','product_image','logo_image','landing_image','shop_logo_image','category_image')->first();
if(empty($get_images) === false)
{
$no_item = $get_images->restaurant_item_image;
$event->order['no_item'] = $no_item;
}
$this->general_setting = DB::table('gr_general_setting')->get();
if(count($this->general_setting) > 0){
foreach($this->general_setting as $s){
$event->order['FOOTERNAME'] = $s->footer_text;
}
}
else {
$event->order['FOOTERNAME'] = 'ePickMeUp';
}
// dd($event->order);
Mail::send('email.order_mail_customer', $event->order, function($message) use($email)
{
dump($email);
// $sub_data = (Lang::has(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS')) ? trans(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS') : trans($this->FRONT_LANGUAGE.'.FRONT_ORDER_SUCCSESS');
// dump($sub_data);
$message->to('googleadmin#gmail.com')->subject('SUCCESSFUL ORDER 😍');
dump('email sent');
});
} catch (\Exception $e) {
// Log Error
// Log::error($e->getMessage());
// Sent Error To Slack
// Dump Error
dump($e->getMessage());
}
}
order_mail_customer.blade.php
<td style="border-top: 5px solid #f7d501;">
<table style="padding:10px;width:100%;">
<tr>
<td align="center">
#php $path = url('').'/public/images/noimage/default_image_logo.jpg'; #endphp
#if(count($logo_settings_details) > 0)
#php
foreach($logo_settings_details as $logo_set_val){ }
#endphp
#if($logo_set_val->admin_logo != '')
#php $filename = public_path('images/logo/').$logo_set_val->admin_logo; #endphp
#if(file_exists($filename))
#php $path = url('').'/public/images/logo/'.$logo_set_val->admin_logo; #endphp
#endif
#endif
#endif
<img src="{{$path}}" alt="#lang(Session::get('front_lang_file').'.ADMIN_LOGO')" class="img-responsive logo" width="100">
</td>
</tr>
</table>
</td>
</tr>
#if($self_pickup==1)
<tr>
<td>
<table style="width:100%;background:url('{{url('public/images/order_image.jpg')}}')no-repeat; padding:56px 20px;">
<tr>
<td colspan="1" style="text-align:center; font-family:cursive; font-size:35px; padding-bottom: 20px; color: #fff;">
#lang(Session::get('front_lang_file').'.FRONT_THANK_ORDER')
</td>
</tr>
<tr>
<td style="text-align:center; font-family:sans-serif; font-size:17px; padding-bottom: 20px; color: #fff; line-height: 25px;">
#lang(Session::get('front_lang_file').'.API_ORDER_PLACED')
</td>
</tr>
<tr>
<td style="text-align:center; font-family:sans-serif; font-size:17px; padding-bottom: 20px; color: #fff; line-height: 25px;">
#lang(Session::get('front_lang_file').'.ADMIN_TRANSACTION_ID') : {{$transaction_id}}
</td>
</tr>
</table>
</td>
</tr>
Why all those #lang(Session::get('front_lang_file') not getting called on queue? Hopefully, someone could help me to solve this problem. Thanks in advance.
Because Queue Job run in process which is diffirent from session process, so, you can't access session ( locale in this case ) . You need pass session as argument for constructor of Job. smth like :
NewOrderListener::dispatch(Event $event, Session $session)

Why does laravel queue ignore my timeout value?

why is my queue job timing out? I am using database as a driver I tried the following:
class PdfGenerator implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $userData;
protected $filename;
protected $path;
public $timeout = 1200;
/**
* Create a new job instance.
*
* #return void
*/
public function __construct($userData, $filename)
{
//
$this->userData = $userData;
$this->filename = $filename;
$this->path = \public_path('\\pdfs\\'.$this->filename.'.pdf');
}
/**
* Execute the job.
*
* #return void
*/
public function handle()
{
$pdf = App::make('snappy.pdf.wrapper');
$footer = \view('supporting.footer')->render();
$header = \view('supporting.header')->render();
//$userData = \collect([$this->userData[1]]);
$pdf->loadView('order_clean', ['users' => $this->userData])
->setOption('margin-top', '20mm')
->setOption('margin-bottom', '20mm')
->setOption('minimum-font-size', 25)
->setOption('header-html', $header)
->setOption('footer-html', $footer);
$pdf->save($this->path);
}
}
php artisan queue:work --timeout=1200
php artisan queue:listen --timeout=0
yet my queue job still fails due to timeout of 60s according to the logs because the symfony process timed out. I am not using supervisor yet, just trying out how the queue works from the console
edit:: controller code + blade code
controller code:
class OrderController extends Controller
{
public function renderPDF()
{
$user_data = $this->getUserData();
$filename = 'test '.\now()->timestamp;
//no timeouts here
//if not ran on queue and with set_time_limit, takes around 70s
//at current data size
$this->dispatch(new PdfGenerator($user_data,$filename));
//view returns successfully
return \view('test.test', ['filename'=>$filename]);
}
}
Blade file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Layout</title>
<style>
*{
font-family: cursive;
}
.wrapper {
display: block;
}
.invoice {
display: block;
width: 80%;
margin: 0 auto;
margin-top: 10px;
padding-top: 10px;
padding-bottom: 10px;
background: #d3d3d3;
page-break-inside: avoid !important;
padding-left: 20px;
}
.order-items {
padding-left: 100px;
}
.table {
width: 90%;
align-self: center;
border: 1px solid black;
orphans: 15;
}
.table>* {
text-align: center;
}
</style>
</head>
<body>
<main class="wrapper">
#foreach ($users as $user)
#php
$orders = $user->orders //just for renaming
#endphp
#foreach ($orders as $order)
<div class="invoice">
#php
$sum=0;
#endphp
<h2>{{$user->name}}: {{$order->id}}</h2>
<div class="order-items">
<table class="table" border="1">
<thead>
<tr>
<th>Product Name</th>
<th>Unit Price</th>
<th>Qty</th>
<th>subtotal</th>
</tr>
</thead>
<tbody>
#foreach ($order->products as $product)
<tr>
<th>
{{$product->name}}<br>
{{$product->name}}<br>
{{$product->name}}<br>
{{$product->name}}<br>
</th>
<td>{{$product->unit_price}}</td>
<td>{{$product->pivot->quantity}}</td>
#php
$sum+= $product->pivot->quantity*$product->unit_price
#endphp
<td>{{$product->pivot->quantity*$product->unit_price}}</td>
</tr>
#endforeach
</tbody>
<tfoot>
<tr>
<th colspan="3">Total:</th>
<td>{{$sum}}</td>
</tr>
</tfoot>
</table>
</div>
</div>
#endforeach
#endforeach
</main>
</body>
</html>
If you want to be able to set the timeouts you should make sure you have the pcntl PHP extension installed and enabled.
"The pcntl PHP extension must be installed in order to specify job timeouts."
Laravel 8.x Docs - Queues - Dispatching Jobs - Specifying Max Job Attempts / Timeout Values - Timeout

jquery not working on using pagination

Am just trying to show all the list in the pagination. am using datatable plugin's pagination on my file, pagination is working fine, in the list i have an image that have a function delete on click. in my pagination 1'st five records is shown . and the other five records shown on click next, delete function working properly on 1'st five record when i click on next than delete function stop it's working .
my code:-
<script>
var conf = jQuery.noConflict();
conf(document).ready(function(){
conf(".delete").on( "click", function() {
alert('adfasdfasd');
//alert(conf(this).attr("id"));
custid = conf(this).attr("id");
var r=confirm("Are you sure");
if (r==true)
{
var url = "<?php echo Mage::getBaseUrl();?>turnkey/index/deleteuser/";
conf.ajax({
type:"POST",
url:url,
data: { 'custid':custid},
success: function(msz){
alert(msz);
if(msz=="deleted") {
conf("#hidepro"+custid).hide("slow");
}
else {
//conf("#hidepro"+proid).hide();
alert("product cant be deleted");
}
//console.log("chal hun");
}
});
}
else
{
return false ;
}
});
});
</script>
and the pagination code is :-
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
} );
</script>
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<thead>
<tr>
<th>Factory</th>
<th></th>
<th>Contact</th>
<th>URL</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
<?php
foreach( $custemail as $custemail1 ) {
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($custemail1); //load customer by email id ?>
<tr class="odd gradeX" style=" border-bottom: 1px solid #FF0000;" id = "hidepro<?php echo $customer['entity_id'] ?>">
<td class="bodyText style4" ><a style=" color: #CC3300;float: left;margin-top: 42px !important;text-decoration: underline;" href="<?php echo Mage::getBaseUrl();?>turnkey/index/listuser?id=<?php echo $customer->getEntity_id();?>"><?php echo $customer->getFactory();?></a> </td>
<td class="bodyText style4">
<a href="<?php echo Mage::getBaseUrl();?>turnkey/index/listuser?id=<?php echo $customer->getEntity_id();?>">
<img style=" width:100px;height:100px;margin-bottom:5px ;" src = "http://lab.ghrix.com/turn-key-mart/media/<?php echo $customer->getUserImage();?>"></a>
</td>
<td class="bodyText style4" style="padding-top: 10px;">
<?php echo $customer->getFirstname();?><?php //echo $customer->getUser_address();?><br><?php echo $customer->getmobile();?><br><?php echo $customer->getEmail();?></td>
<td class="bodyText style4" style="float: left;margin-top: 42px !important;" >
<a target="_blank" style="color:#005580;" href="<?php echo $customer->getWebsite();?>"><?php echo $customer->getWebsite();?></a></td>
<td class="bodyText style4"><div style= "cursor:pointer;" class = "delete" id = "<?php echo $customer['entity_id'] ?>"><img width="60px" src="<?php echo $this->getSkinUrl('images/trash.jpg'); ?>"</div></td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
please suggest where mistake is happen.
Without a live example, I can't be sure, but try this:
replace
conf(".delete").on("click", function() ...
with:
conf(document).on("click", ".delete", function() ...
The reason is that conf(".delete") only attaches to elements available at the time the function is run. It might be that your dataTable plugin runs first, removes the extra elements, then the delete binder is run and only works on the first 5. The second method binds to the document, and checks each click to see if it matches the .delete selector. This used to be known as jQuery.live()

How to filter part of view in zend framework

I have a view in zend in which we have the form to submit entry and on bottom we have listed the previous entries. i have applied the search functionality and its working fine when we click on search button. Now what i want is to apply search on keyup event using getJSON event so we can instantly search the content.
I have added two condition for seach...for search using search button click.
if($req->isPost()) {
{
//$ajaxPostedData = $req->getPost();
$ajaxPostedData = $req->getParams();
//echo $ajaxPostedData['search_term'];
$select->where("ma_heading like '%".$ajaxPostedData['search_term']."%'");
//$select->where($val)
//echo $select->__toString();die;
//print_r($data = $db_model->fetchAll($select));
//die;
//echo $select->__toString();
return $data = $db_model->fetchAll($select);
# Paging section
$paginator = Zend_Paginator::factory($data);
$paginator->setItemCountPerPage(PAGING_RESULT_PER_PAGE);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(PAGING_PAGES_RANGE_PER_PAGE);
$this->view->data = $paginator;
//$this->_helper->P($ajaxPostedData);die;
//
}
and for keyup event
if($req->isXmlHttpRequest())
{
//$ajaxPostedData = $req->getPost();
$ajaxPostedData = $req->getParams();
//echo $ajaxPostedData['search_term'];
$select->where("ma_heading like '%".$ajaxPostedData['search_term']."%'");
//$select->where($val)
//echo $select->__toString();die;
//print_r($data = $db_model->fetchAll($select));
//die;
//echo $select->__toString();
return $data = $db_model->fetchAll($select);
# Paging section
$paginator = Zend_Paginator::factory($data);
$paginator->setItemCountPerPage(PAGING_RESULT_PER_PAGE);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(PAGING_PAGES_RANGE_PER_PAGE);
$this->view->data = $paginator;
//$this->_helper->P($ajaxPostedData);die;
//
}
But the content is not replace dynamically when we are searching the content on keyup.
Please help me how can i apply keyup search in zend.
This is the jQuery script which i have used to send request
jQuery('#txt_heading_filer').keyup(function() {
var heading = jQuery('#txt_heading_filer').val();
$.getJSON('admin/admin/announcements/search_term/'+heading, function() {
});
});
This is the table which need to refreshed on search
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="top-table-bg">
<tr>
<th width="" align="left"><?php echo $obj_trans->_('heading'); ?></th>
<th width="20%" align="left"><?php echo $obj_trans->_('expiry date'); ?></th>
<th width="10%" align="center"><?php echo $obj_trans->_('publish/unpublish'); ?></th>
<th width="10%" align="center"><?php echo $obj_trans->_('action'); ?></th>
</tr>
<?php
foreach($data_arr as $key => $data) { ?>
<tr>
<td align="left" class="name" ><span><?php echo $data[PREFIX_MASTER_ANNOUNCEMENTS . 'heading']; ?></span></td>
<td align="left" class="name">
<?php echo (!empty($data[PREFIX_MASTER_ANNOUNCEMENTS . 'expiry_date'])) ? date("j", strtotime($data[PREFIX_MASTER_ANNOUNCEMENTS . 'expiry_date'])).'<sup>'.date("S", strtotime($data[PREFIX_MASTER_ANNOUNCEMENTS . 'expiry_date'])).'</sup> '.date("M, Y", strtotime($data[PREFIX_MASTER_ANNOUNCEMENTS . 'expiry_date'])) : "N/A"; ?>
</td>
<td align="center">
<?php Admin_View_Helper_GeneralHelper::status_icon($data[PREFIX_MASTER_ANNOUNCEMENTS . 'status']); ?></td>
<td align="center">
<?php echo $this->img("img/admin/icons/edit.png", array('id' => 'icon_edit')) ?>
<?php echo $this->img("img/admin/icons/delete.png", array('id' => 'icon_delete')) ?>
</td>
</tr>
<?php } ?>
</table>
First you have to put the table in a div with an id
<div id='search-result-table'>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="top-table-bg">
<!-- rows here -->
</table>
</div>
Then on the js function, call the ajax and replace the contents in the div with the response
var heading = jQuery('#txt_heading_filer').val();
var url = 'admin/admin/announcements/search_term/'+heading;
$.get(url, function(data) {
$('#search-result-table').html(data.result);
});
Then prepare the result. There is no need for the if($req->isPost()) condition. You have to call the paginator for for all type of requests.
if($req->isXmlHttpRequest())
{
$this->_helper->viewRenderer->setNoRender(); //Disable view
$this->_helper->layout->disableLayout(); //Disable layout
$html = $this->view->render('searchresult.phtml'); //Create a new view file in the script location and put the result (same code as in the view page) in it
echo Zend_Json::encode(array('result'=>$html)); //Get the result and encode it
}
In searchresult.phtml:
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="top-table-bg">
<!-- rows here -->
</table>

Validating php form - How to show error message on the form

I've been receiving blank submissions from my form and I know that validating ("required" validation) using javascript isn't always effective because spambots can turn off javascript.
So I've been looking for ways to validate my php form using php.
So after a but of research ... I found that this will work:
if (!$_POST['name'] )
{
die('Please fill in your name');
}
Though, this message 'Please fill in your name' shows on a different page after I've hit the submit button. Now ideally, I'd like that message to display on the page where the form is, though I'm struggling to find a way to do this. (Please excuse my lack on knowledge on php).
Would I require Ajax?
I assume I would need to add a div on the form page where I want the error message to display? How would I ask php to display the error message on the form page? IE: What would I need to put in my php process form (along with the code above?).
If you need me to post / add any more detail, please ask, as I'd appreciate your help!
======================================================================
UPDATE
Here is my php process form:
<?
session_start();
include("verification_image.class.php");
$image = new verification_image();
if (($image->validate_code($_POST['validate']) ? "true" : "false") == "false") {
header('Location: http://www.domain.com/fail.htm');
exit;
}
if (!$_POST['rgerger'] )
{
die('You did not complete all of the required fields');
}
if(!empty($_POST['email'])){ die('Stop Spamming'); }
$to = "email#address.co.za";
$from = $_POST['ervberster'];
$subject = "I Want to Advertise";
$sBodyNew = '<style type="text/css">
<!--
.style {
font-family: Arial;
font-size: 12px;
color: #4D241E;
}
body {
background-image: url();
background-color: #F1EAE4;
}
.style1 {font-size: 14px}
-->
</style>
<p> </p>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td><table width="100%" border="0" cellpadding="8" cellspacing="0" bgcolor="#E7D3AF"
class="style">
<tr>
<td colspan="2" valign="top"><div align="center"><strong><span class="style1">I
Want to Advertise on AccommodationMozambique.co.za</span><br>
.................................................</strong><br>
</div></td>
</tr>
<tr>
<td width="32%" valign="top"><div align="left"><strong>Date Submitted</strong>
</div></td>
<td width="68%" valign="top">'. date("F j, Y, g:i a") .'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Name</strong></div></td>
<td valign="top">'.$_POST['name'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Email</strong></div></td>
<td valign="top">'.$_POST['ervberster'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Telephone</strong></div></td>
<td valign="top">'.$_POST['werergrggef'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Name of Lodge</strong></div></td>
<td valign="top">'.$_POST['hneyjyttyh'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Town / City</strong></div></td>
<td valign="top">'.$_POST['gedghethth'].'</td>
</tr>
<tr>
<td valign="top"><div align="left"><strong>Enquiry</strong></div></td>
<td valign="top">'.$_POST['rervberer323'].'</td>
</tr>
</table></td>
</tr>
</table>
';
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $subject, $sBodyNew, $headers);
header('Location: http://www.domain.com/success.htm');
?>
As you mentioned, yes, JavaScript can be turned off - not just by spambots, by anybody. JavaScript is a client-side language, so the validation happens on the client-side. Basing security on hoping that your client does what you want, is bad. Never trust user input.
That being said, you're on the right path with your PHP validation, except doing a die() will cause your page to stop executing before you have even printed your form. A common way to do this is doing something like this
$errors = array();
if (strlen($_POST['name']) < 5)
$errors[] = "Username not long enough.";
if (usernameAvailable($_POST['name']))
$errors[] = "Username already taken.";
if (otherValidationRule())
$errors[] = "Something else isn't right.";
if (sizeof($errors) > 0) {
foreach($errors as $error)
{
printf("<li>%s</li>", $error);
}
}
else {
print "Your data is OK!";
// Do whatever you want with the data.
}
This will print "Your data is OK!" if nothing is wrong with the user input, otherwise it will print a list of all errors encountered. That could be something like
Username not long enough.
Something else isn't right.
Getting just one error at a time gives a bad user experience, as you might end up having to submit your form 5 times, because every time you fix one thing, a new error comes up.
If you're using the same page for multiple form, the best way would be adding hidden input:
<input type='hidden' name='action' value='sendMail' />
Than in PHP:
if( isset( $_POST['action'])){
switch( $_POST['action'])){
case 'sendMail':
$msg = check_my_mail_form();
if( $msg !== null){
echo "Failed to send...";
}
}
}
function check_my_mail_form() {
if( !isset( ...){
return 'Please fill name';
}
return null;
}
Of course you should use different and little more complicated object oriented design (such as class with methods as validate() and getError()), but this should be good place to start for you.
It depends on how you are submitting the form. Presuming that you're submitting the page itself, then at the top of the page add something like this:
<?php
$warnings = "";
if (isset($_POST)){ //if post variables have been sent then we validate
if (!isset($_POST['name']) || trim($_POST['name'])==''){ //if the variable isn't set or if it's empty
$warnings .= "<p>You must provide a name</p>";
}
}
?>
and then, in the html of the page, where you'd want the warning to be displayed, you'd add:
<?php
echo $warning;
?>
Also, note my validate syntax: if (!isset($_POST['name']))... this will return true there is not variable $_POST['name'], whereas if(!$_POST['name]) will only return true if, at some point, you set $_POST['name'] = false;
Make you you keep in mind that ![item] means "item is false", !isset([item]) means "the variable doesn't exist, and [item]=='' means that the item exists, and that it's an empty string. These are all separate things.

Categories