isset if statement doenst work on my mamp. dont know why..

Ive been learning php off tutorials on youtube.
When i come to using isset in an if statement it causes nothing to show.
Im on a local mamp server.
I have no idea why it wont work, have tried a few diff error configs and buffer flush.
Nothing showing in my error log. Any help?

[php]

<?php /* ini_set('error_reporting', 'E_ALL & E_STRICT'); ini_set('error_reporting', ' E_ALL & ~E_NOTICE & ~E_STRICT'); // from other tute, didnt work echo 'hello world'; if(isset($_GET['user_name'])&&!empty($_GET['user_name']){ $user_name = $_GET['user_name']; $user_name_lc = strtolower($user_name); if($user_name_lc=='julius'){ error_log("TRUE"); print 'You are the best' .$user_name; } } */ //$user_input = 'd'; //$user_input = ''; //$user_input = null; ################################################# echo '
Tutorial 52 - swear filter

'; //ob_start(); ///* if(isset($_POST['user_input'])&&!empty($_POST['user_input']){ echo 'works'; } //*/ //ob_end_flush(); ?>

[/php]

<!--
<html>
<form action ="test2.php" method = "GET">
Name: <input type = "text" name = "user_name"><br><br>
<input type="submit" value="Submit">
</form>
</html>

-->

<form action ="test.php" method = "POST">
<textarea name = "user_input" rows = "6" cols = "30"></textarea><br><br>
<input type = "submit" value = "Submit">
</form>

[php]if(isset($_POST[‘user_input’])&&!empty($_POST[‘user_input’]){
echo ‘works’;
}[/php]

You were missing a ) at the end
[php]if( isset($_POST[‘user_input’]) &&!empty($_POST[‘user_input’]) ){[/php]

Add error_reporting(E_ALL); to the start of your script to display errors

The error reporting is there, but he commented it out. Just needs to move the comment starter (/*) to the front of the second ini_set().

thanks so much. i cant believe i missed that. cheers :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service