Grantmau5 Posted November 5, 2009 Share Posted November 5, 2009 Sorry guys i hate this registering for an answer then leaving but i really need help. heres my code. if(isset($_POST['send'])){ // Take user's name and say hello START $rname = $_POST['rname']; $dname = $_POST['dname']; if($rname == null){ ob_start(); echo "JPi Encountered an error. Please try entering your real name again."; $page = "preferences.html"; header("Refresh: 5; URL=\"" . $page . "\""); ob_flush(); } else { echo "Welcome, " . $rname . " to the JPi BOT. \r\n"; echo "Your current Display name is: " . $dname . ". \r\n"; // Take user's name and say hello END } } Basically if field equals null then give error and return to page else print the welcome message. For some reason it isn't working and i really can't spot my flaw. Any help guys ? Ps. I have also tried using empty, !isset, is_null... Quote Link to comment https://forums.phpfreaks.com/topic/180489-php-if-null-do-code/ Share on other sites More sharing options...
Alex Posted November 5, 2009 Share Posted November 5, 2009 What is happening then? empty() should work. Quote Link to comment https://forums.phpfreaks.com/topic/180489-php-if-null-do-code/#findComment-952159 Share on other sites More sharing options...
Grantmau5 Posted November 5, 2009 Author Share Posted November 5, 2009 Thank you for the suggestion. However the header isnt the problem here. On the previous page i have two input fields: one for the user's real name and the other for a display name. Im trying to redirect them back if the real name input field is empty (null) . Otherwise i greet them announcing them by name. and no i tried the empty() function but still doesnt work. Looking at my code im sure it should work :'( Quote Link to comment https://forums.phpfreaks.com/topic/180489-php-if-null-do-code/#findComment-952162 Share on other sites More sharing options...
Alex Posted November 5, 2009 Share Posted November 5, 2009 if(empty($rname)) should work. Are you sure you're using the correct name to access the value? You're telling us something is wrong, but you're not telling us what's happening. Quote Link to comment https://forums.phpfreaks.com/topic/180489-php-if-null-do-code/#findComment-952164 Share on other sites More sharing options...
Grantmau5 Posted November 6, 2009 Author Share Posted November 6, 2009 Never mind the code was correct. As you rightly pointed out it was an issue with the html, not the name part but i had onClick="value=' '" << i had a space inside the single quotes. Ah it's because it's midnight here, my heads not on properly. Thanks for the knock on the head i needed Quote Link to comment https://forums.phpfreaks.com/topic/180489-php-if-null-do-code/#findComment-952167 Share on other sites More sharing options...
Alex Posted November 6, 2009 Share Posted November 6, 2009 Np Happens to everyone. Just make sure to mark the topic as solved, there's a button on the bottom left to do so. Quote Link to comment https://forums.phpfreaks.com/topic/180489-php-if-null-do-code/#findComment-952174 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.