mike12255 Posted December 16, 2011 Share Posted December 16, 2011 Alright so what im trying to say probably wont make much sense so I have also setup a live demo that I will explain at the end. I have a file upload form (that works). While uploading the file it tests agains a few things but mainly to see if the file has already been uploaded into the database by anyone. If it has I want to return an error inside a fieldset with a legend that says "Error". The problem is the fieldset or legend do not show up and I dont know why. The demo: I have created a test account for this, you will need to go to: http://www.nipnotes.com/login.php and login with the username: test and password: test then click on upload note at the top of the page go through the processs uploading anything (.rtf .doc .docx .txt format). Then try and upload that exact same file again and you will see an error in red text. I want that error to be inside the fieldset with the legend "Error". I dont know if my tired eyes missed something small or I just completly fked it up but ill post the code for that section below. <div id="container" class="clear"><!-- ####################################################################################################### --> <div id="content"> <?php // Edit the uploader into here $query = "SELECT * FROM catagories ORDER BY name ASC"; $uploadLocation = $_SERVER ['DOCUMENT_ROOT'] . "/uzEr Upl0ds/"; ?> <form id="upload" action="<?php echo $_SERVER ['PHP_SELF']; ?>" method="post" name="fileForm" class="login" enctype="multipart/form-data"> <?php if ($session->logged_in) { ?> <table class="uploadForm"> <tr> <td><label>Select The Program The Note Is For:</label></td> </tr> <? $res = mysql_query ( $query ) or die ( mysql_error () ); ?> <tr> <td><select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Program</option> <?php getTierOne (); ?> </select></td> </tr> <tr> <td><label for="code">Select The Course Code/Name</label></td> </tr> <tr> <td><span id="wait_1" style="display: none;"> <img alt="Please Wait" src="images/ajax-loader.gif" /> </span> <span id="result_1" style="display: none;"></span> </tr> </td> </td> </tr> <tr> </tr> <tr> </tr> <tr> <td><label> Note Title eg. Police Foundations</label></td> </tr> <tr> <td><input name="title" type="text" /></td> </tr> <input type="hidden" name="author" value="<? $session->username; ?>" /> <tr> <td><input name="upfile" type="file" size="36".></td> </tr> <tr> <td align="center"><br /> <input class="login" type="submit" name="submitBtn" value="Upload" /></td> </tr> </table> </center> <?php } else { //user is not logged in echo "<p>Sorry, but you must be logged in to upload notes. If you already have account you can login <a href=\"login.php\">here</a>. If you do not yet have an account you can register a free account <a href=\"register.php\">here</a> its fast and enables all the features this website has to offer."; } if (isset ( $_POST ['submitBtn'] )) { if ($_FILES ['upfile'] ['tmp_name'] != "") { if (! empty ( $_POST ['title'] )) { ?> <div id="caption">RESULT</div> <div id="icon2"> </div> <div id="result"> <table width="100%"> <fieldset><legend>Error</legend> <?php //run basic md5 check now to quick flush out options $newmd5 = md5_file ( $_FILES ['upfile'] ['tmp_name'] ); switch (firstMd5Check ( $newmd5, $session->username )) { case 1 : $target_path = $uploadLocation . basename ( $_FILES ['upfile'] ['name'] ); $ext = end ( explode ( '.', $_FILES ['upfile'] ['name'] ) ); function generatePassword($length = { // start with a blank password $password = ""; // define possible characters - any character in this string can be // picked for use in the password, so if you want to put vowels back in // or add special characters such as exclamation marks, this is where // you should do it $possible = "_12346789abcdfghjkmnpqrtvwxyzABCDFGHJKLMNPQRTVWXYZ"; // we refer to the length of $possible a few times, so let's grab it now $maxlength = strlen ( $possible ); // check for length overflow and truncate if necessary if ($length > $maxlength) { $length = $maxlength; } // set up a counter for how many characters are in the password so far $i = 0; // add random characters to $password until $length is reached while ( $i < $length ) { // pick a random character from the possible ones $char = substr ( $possible, mt_rand ( 0, $maxlength - 1 ), 1 ); // have we already used this character in $password? if (! strstr ( $password, $char )) { // no, so it's OK to add it onto the end of whatever we've already got... $password .= $char; // ... and increase the counter by one $i ++; } } // done! return $password; } $filename = generatePassword (); $filename = $filename . "." . $ext; $filelocation = $_SERVER ['DOCUMENT_ROOT'] . "/uzErUpl0ds/" . $filename; $allowed = "doc docx rtf txt pdf xls"; $allow = explode ( " ", $allowed ); if (in_array ( $ext, $allow )) { if (move_uploaded_file ( $_FILES ['upfile'] ['tmp_name'], $filelocation )) { //TODO: Insert date regex format and make the catagory selection auto// $uid = $_POST ['catagory']; $name = $_POST ['title']; $author = $session->username; $pid = $_POST ['drop_1']; $cat = $_POST ['tier_two']; $dt1 = date ( "Y-m-d" ); $size = filesize ( $filelocation ); $query = "INSERT INTO newnotes (uid, name, catagory, location, author, date, filesize,pid,md5) VALUES ('$uid', '$name', '$cat', '$filename', '$author', '$dt1','$size','$pid','$newmd5')"; //die ($query); $res = mysql_query ( $query ) or die ( mysql_error () ); echo "<div style=\"color:#057820\";>The file: " . basename ( $_FILES ['upfile'] ['name'] ) . " has been uploaded! It will be reviewed and if possible you will be granted credits within the next 24 hours."; } else { echo "There was an error uploading the file, please try again!"; } } else { //invalid extenion type echo "<div style=\"color: #F00\";>It appears that you have tried to upload an invalid file type. We accept the types " . $allowed . " if this appears to be a mistake on our end or you have a file type that should be allowed you can contact us <a href=\"contact.php\">here</a></div>"; } break; case 2 : //file is already in newnotes could be a possible double click $query = "UPDATE users SET warnings = warnings + 100 WHERE username = '" . $session->username . "'"; if (mysql_query ( $query ) or die ( mysql_error () )) { echo "<p style=\"color: #F00\";> The file you are trying to upload is already in the queue to be verified. This could be the result of double click and for which we will not ban you. This has been noted and if in the future your account continues to encounter this issue further action will be taken. Please make sure you are only clicking the submit button. If you have any issues you can contact us <a href=\"contact.php\">here</a></p>"; } break; case 0 : //user uploaded a file that either he has uploaded or has downloaded ban him. $query = "UPDATE users SET warnings = warnings + 1 WHERE username = '" . $session->username . "'"; if (mysql_query ( $query ) or die ( mysql_error () )) { $reason = "You have tried to upload a note that has either been uploaded previously by you or that you have downloaded before in the past."; if (banUser ( $session->username, $reason )) { echo "<div style=\"color: #F00\";> " . $reason . " As a result your account has been banned. You may appeal to have your account unbanned once by going here: <a href=\"appeal.php\">appeal</a> It is recommended you bookmark that link until you are ready to apeal because you will not find it anywhere else.</div>"; } } break; ?> <?php } } else { //no file name was gi echo "<div style=\"color: #F00\";>You either forgot to enter a note name or entered one to short, please go back and try again.</div>"; } } else { echo "<div style=\"color: #F00\";>You forgot to select a file to upload, please try again.</div>"; } echo "</fieldset></form></table></div>"; } else { echo "</form>"; } ?> <!-- Content Ending Div --> </div> Quote Link to comment https://forums.phpfreaks.com/topic/253325-fieldset-and-legend-not-working/ Share on other sites More sharing options...
kicken Posted December 16, 2011 Share Posted December 16, 2011 http://www.nipnotes.com/styles/forms.css Lines 15-17: legend{ display:none; } That is why it does not display. Quote Link to comment https://forums.phpfreaks.com/topic/253325-fieldset-and-legend-not-working/#findComment-1298660 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.