Nexy Posted June 21, 2008 Share Posted June 21, 2008 Why Hello There! I don't see why this problem is happening. <?php $shomes = mysql_real_escape_string(stripslashes($_POST['shoutext'])); $sshuser = mysql_real_escape_string(stripslashes($_SESSION['username'])); $cshuser = mysql_real_escape_string(stripslashes($_COOKIE['user'])); $shtime = mysql_real_escape_string(stripslashes(date('h:i:s a'))); $sherror = "0"; if($_POST['shoutsub']) { if(!empty($shomes)) { if($_SESSION['username']) { mysql_query("INSERT INTO shoutbox(user, time, message) VALUES('$sshuser', '$shtime', '$shomes')"); } else if($_COOKIE['user']) { mysql_query("INSERT INTO shoutbox(user, time, message) VALUES('$cshuser', '$shtime', '$shomes')"); } } else if(empty($shomes)) { $sherror = "1"; } } ?> <div class='create margin' style='font-size: .8em; width: 700px; margin-top: .8em; margin-bottom: 0'> Shoutbox ( <a href="javascript:;" onmousedown="if(document.getElementById('shoutbox').style.display == 'none' || document.getElementById('shoutform').style.display == 'none') { document.getElementById('shoutbox').style.display = 'block'; document.getElementById('shoutform').style.display = 'block'; } else { document.getElementById('shoutbox').style.display = 'none'; document.getElementById('shoutform').style.display = 'none' } ">Show/Hide</a> ) </div> <div id="shoutbox" style="display:none"> <?php $shsql = "SELECT * FROM shoutbox WHERE id > 0 ORDER BY id DESC"; $shres = mysql_query($shsql) OR die(mysql_error()); while($shout = mysql_fetch_array($shres)) { echo $shout['time'] . " " . $shout['user'] . ': ' . $shout['message'] . '<br />'; } ?> </div> <?php if($_SESSION['username'] || $_COOKIE['user']) { echo "<div id='shoutform' style='display: none'>"; if($_POST['shoutsub'] && $sherror == "1") { echo "<span style='color: red'>Please enter a message!</span>"; } echo "<form action='#' method='post'> <fieldset id='shout'> <label for='shoutext'>Message:</label> <input type='text' id='shoutext' name='shoutbox' tabindex='6' style='width: 500px' /> <input type='submit' id='shoutsub' name='shoutsub' value='Shout!' tabindex='7' /> </fieldset> </form> </div>"; } ?> The problem is, it keeps telling me "Please enter a message". I know this isn't the best way to do a shoutbox, I will use AJAX later, but does anyone see any reason as to why it would keep saying that even after I enter something? I can't tell if the INSERT statements are working or not because it never gets there. I echoed "$shomes" but it returned nothing. Any help would be appreciated. Thank You! Quote Link to comment https://forums.phpfreaks.com/topic/111204-solved-empty-problem-possibly/ Share on other sites More sharing options...
awpti Posted June 21, 2008 Share Posted June 21, 2008 Echo out $_POST['shoutext']; Did you mean $_POST['shoutbox']; ? Your input name isn't 'shoutext', it's shoutbox. Quote Link to comment https://forums.phpfreaks.com/topic/111204-solved-empty-problem-possibly/#findComment-570814 Share on other sites More sharing options...
Nexy Posted June 21, 2008 Author Share Posted June 21, 2008 Oh wow! the "name" was the problem. Thank You so much! Quote Link to comment https://forums.phpfreaks.com/topic/111204-solved-empty-problem-possibly/#findComment-570825 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.