Jump to content

etsted

Members
  • Posts

    274
  • Joined

  • Last visited

Everything posted by etsted

  1. etsted

    different heights

    here i have a script that i run several times with a while loop bu every time the loop runs the next div has a higher margin-top than the next div $videos .= "<div class='files' style='float:left; background:#eaeaea; width:150px; color: black;' id='file_".$id."'>n <a href='watch.php?f=".$file_url[0]."'><img src='$avatar' height='60' width='60' alt='$titel'> Click here</a> <br> <span style='float:left; text-overflow:ellipsis;'>Titel: $titel</span>n <br> <span>Uploaded by: <a href='user.php?u=$username'>$username</a></span> <br> <br> </div>n <br> <br>n";
  2. // this makes every file name unique $fileName = $_FILES['Filedata']['name']; $kaboom = explode(".",$fileName); $ext = ""; $ext = end($kaboom); $ext = strtolower($ext); $fileName = date("YmdjzHhisu") . rand(10000000,99999999) . ".$ext"; // defines what the ext can be $imageTypes = array('jpg','jpeg','gif','png'); $videoTypes = array('mp4','webm','ogg','wmv'); $audioTypes = array('mp3','ogg','wav'); $title = $_POST['title']; $description = $_POST['description']; $username = $_POST['username']; // include DB connection include_once ("../connect.php"); // use the pathinfo to match the ext of the uploaded file $fileParts = pathinfo($_FILES['Filedata']['name']); $fileParts = $fileParts['extension']; $fileParts = strtolower($fileParts); if (in_array($fileParts,$imageTypes)) { // this is for images // insert into DB $sql = "INSERT INTO images VALUES('', '$title', '$description', '$username', '$fileName' , NOW(), '')"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "../u_image/" . $fileName); echo '1'; } else if(in_array($fileParts, $videoTypes)){ // this is for videos // insert into DB $sql = "INSERT INTO videos VALUES('', '$title', '$description', '$username', '$fileName' , NOW(), '')"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "../videos/" . $fileName); echo '1'; } else if(in_array($fileParts,$audioTypes)){ // this is for audios // insert into DB $sql = "INSERT INTO mp3 VALUES('', '$title', '$description', '$username', '$fileName' , NOW(), '')"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "../audio/" . $fileName); echo '1'; } else { echo "Invalid file."; } this script is supposed to store images , videos and mp3. It only store images not mp3 or video file. I have created the map for mp3 videos and images.
  3. etsted

    browser detect

    i dont find any functions for detecting browser type. I am trying to build an application so that depending on the users browser the HTML5 mediaplayer will use a different extension for the file being played.
  4. get the properties of the page
  5. CREATE TABLE IF NOT EXISTS comments ( id INT(11) NOT NULL, osid INT[11) NOT NULL, account_name VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL, type ENUM NOT NULL, data TEXT, postdate DATETIME, PRIMARY KEY (id), ) It says i have an error at line 3
  6. I know you can use javascript to hide elements, as a "delete option", but is that really the only way, or the most effecient?
  7. etsted

    jquery

    It says in w3schools.com that you should use document.write
  8. actually i dint fix it here is the updated code: $errorPass = $successPass = $oldPass = $newPass = $repeatNewPass=""; // this is used to change someones password if(isset($_POST['changePass'])){ // check to make sure they have written in their old password if(empty($_POST['oldPass'])){ $errorPass .= "Fill out Old password field<br>"; } else { $oldPass = mysqli_real_escape_string($con, $_POST['oldPass']); } // check to make sure they have written in their new password if(empty($_POST['newPass'])){ $errorPass .= "Fill out New password field<br>"; } else { $newPass = mysqli_real_escape_string($con, $_POST['newPass']); } // check to make sure they have reapeated their new password if(empty($_POST['repeatNewPass'])){ $errorPass .= "Fill out Repeat new password field<br>"; } else { $repeatNewPass = mysqli_real_escape_string($con, $_POST['repeatNewPass']); // check to make sure that $newPass and $repeatNewPass matches if($newPass != $repeatNewPass){ $errorPass .= "Your new passwords does not match<br>"; } } // hash the password, before testing it against the DB function protect_pass($val) { return md5($val); } if(empty($errorPass)){ $password = protect_pass($oldPass); // check to make sure their old password is correct $sql = "SELECT password FROM register WHERE password='$password'"; $query = mysqli_query($con, $sql); $numrows = mysqli_num_rows($query); if($numrows < 1){ $errorPass .= "Your old password is not correct<br>"; } else { $password = protect_pass($newPass); $sql = "UPDATE register SET password='$password' WHERE u_name='$log_username'"; $query = mysqli_query($con, $sql); if($query == true){ $successPass = "Your password has been changed<br>"; // make a new cookie with their password, else they will be logged out $expire=time()+60*60*24*30; setcookie("password", $password, $expire); } else { $errorPass .= "Some unexpected error occured while trying to change your password<br>"; } } } Here is the script that checks to see if the user is logged in <?php session_start(); // include DB connection include_once "connect.php"; // This script checks to see if a user is logged in $user_status = false; $log_username = ""; $log_password = ""; function eval_user($con, $user, $pass) { $sql = "SELECT u_name, password FROM register WHERE u_name='$user' AND password='$pass' AND activated='1' "; $query = mysql_query($sql); $numrows = mysql_num_rows($query); if($numrows > 0){ return true; } } if(isset($_SESSION['username']) && isset($_SESSION['password'])) { $log_username = preg_replace('#[^a-z0-9]#i', '', $_SESSION['username']); $log_password = preg_replace('#[^a-z0-9.!#%&]#i', '', $_SESSION['password']); // verify the user $user_status = eval_user($con, $log_username, $log_password); } else if(isset($_COOKIE['username']) && isset($_COOKIE['password'])) { $_SESSION['username'] = preg_replace('#[^a-z0-9]#i', '', $_COOKIE['username']); $_SESSION['password'] = preg_replace('#[^a-z0-9.!#%&]#i', '', $_COOKIE['password']); $log_username = $_SESSION['username']; $log_password = $_SESSION['password']; // verify the user $user_status = eval_user($con, $log_username, $log_password); }?>
  9. Hi my username is etsted, and i am not new but i can still say something. I just finished my website. Its a upload type website. If you like it, let me know, and if you want to know more about the website or me, tell me. Other than that? no. Theres not much
  10. I have a simple drop down select list, but when one of the option elements is empty <option value=""></option> or <option></option> I get an error when i try to validate the script: Line 213, Column 17: Element option without attribute label must not be empty. <option></option>
  11. if you tried my script out maybe you could see something wrong from there.
  12. the only other css i have included is in a file style/styles.css body { margin: 0px; min-width: 100%;}/* topDiv */ /* #topDiv, the main top div */ #topDiv{ min-height: 90px; background-color: #00ff00; margin: 0px; padding: 0px; border: 0px; overflow: hidden; min-width: 1000px; } /* used to design the logo */ #topDiv > #Logo{ margin-left: 30px; float: left; width: 120px; height: 90px; } /* used inside the first div of topDiv */ #topDiv > #inside1_topDiv { height: 45px; margin-top: 20px; margin-right: 50px; float: right; } /* use this to change the links that are inside #inside1_topDiv */ #topDiv > #inside1_topDiv > a{ margin: 20px; color: #004000; text-decoration: none; } /* use this to change the hover state of links that are inside #inside1_topDiv */ #topDiv > #inside1_topDiv > a:hover{ margin: 20px; color: #ffffff; } /* used inside the second div of topDiv */ #topDiv > #inside2_topDiv { height: 45px; margin-left: 20px; border: 1px solid red; float: left; } /* use this to change the links that are inside #inside2_topDiv */ #topDiv > #inside2_topDiv > a{ margin: 20px; color: #004000; text-decoration: none; } /* use this to change the hover state of links that are inside #inside2_topDiv */ #topDiv > #inside2_topDiv > a:hover{ margin: 20px; color: #ffffff; } /* used inside the first div of topDiv */ #topDiv > #inside3_topDiv { clear: both; margin: -21px 0px 0px 335px; float: left; }/* topDiv *//* middleDiv */#middleDiv{ float: left; min-width: 100%; min-height:600px; background: #f4f4f4;}/* middleDiv *//* bottomDiv */#bottomDiv{ text-align: center; margin-bottom: 0px; padding: 24px; clear: both; min-width: 1215px;; float:left; background: #00ff00;}/* bottomDiv *//* used for coloring error */.error{ color: red;}
  13. any reason to why if($username == $u){ $deleteBtn = '<a href="#" onclick="return false" onmousedown="delete('file_'.$id.'',''.$db_table.'')">Delete</a>'; } function wont run? function db_table($queryAgainst, $db_table){ global $con; global $output; global $u; $query = mysqli_query($con, $queryAgainst) or die(mysqli_error($con)); while($row = mysqli_fetch_array($query)){ $id = $row['id']; $title = $row['tittel']; $description = $row['description']; $username = $row['username']; $file_url = $row['file_url']; $upload_date = $row['upload_date']; $avatar = $row['avatar']; // give their files an avatar , if they dont already have one if($avatar == NULL) { $avatar = "images/avatardefault.png"; } else { $avatar = "user/$username/$avatar"; } $file_url = explode(".", $file_url); // give the owner if($username == $u){ $deleteBtn = '<a href="#" onclick="return false" onmousedown="delete('file_'.$id.'',''.$db_table.'')">Delete</a>'; } $output .= '<div id="file_'.$id.'" class="files" style="background: #37ff37; width:250px; color: black; float: left; margin: 3px;"> <a href="watch.php?f='.$file_url[0].'"><img src="'.$avatar.'" height="80" width="85" alt="'.$title.'"> Watch</a> '.$deleteBtn.' <br> <div style="overflow:hidden; text-overflow:ellipsis; ">Tittel: '.$title.'</div> <br> <span>Uploaded by: <a href="user.php?u='.$username.'">'.$username.'</a></span> <br> <div style=" overflow: hidden; word-wrap:break-word; height:60px;">Description: '.$description.' </div> <br> <span>Upload date: '.$upload_date.'</span> <br> </div>' . "nn"; } } db_table($videos, "videos"); db_table($images, "images"); db_table($mp3, "mp3"); The javascript that correspond <script>function delete(fileId,db_table){ var ajax = ajaxObj("POST", "php_parsers/usersFiles_system.php"); alert("hi"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) == true) { if(ajax.responseText == "delete_ok"){ // remove the div all of the tekst is inside, the textarea and the reply button _(fileId).style.display = 'none'; } else { alert(ajax.responseText); } } } ajax.send("action=delete_file&db_table="+db_table+"&file_id="+fileId);}</script>
  14. did anyone figure it out? why does my jQuery slidedown() function, somehow slide my div up again?
  15. this is the form you have to fill out <form action="" method="post" name="changePass" id="changePass"> Old password: <input type="password" name="oldPass" style="margin-left: 50px;"> <br> New password: <input type="password" name="newPass" style="margin-left: 43px;"> <br> Repeat new password: <input type="password" name="repeatNewPass" style="margin-left: 1px;"> <br><br> <input type="submit" name="changePass" value="Change password"> </form>
  16. why does this cript keep logging me out when i change my password? $errorPass = $successPass = $oldPass = $newPass = $repeatNewPass=""; // this is used to change someones password if(isset($_POST['changePass'])){ // check to make sure they have written in their old password if(empty($_POST['oldPass'])){ $errorPass .= "Fill out Old password field<br>"; } else { $oldPass = mysqli_real_escape_string($con, $_POST['oldPass']); } // check to make sure they have written in their new password if(empty($_POST['newPass'])){ $errorPass .= "Fill out New password field<br>"; } else { $newPass = mysqli_real_escape_string($con, $_POST['newPass']); } // check to make sure they have reapeated their new password if(empty($_POST['repeatNewPass'])){ $errorPass .= "Fill out Repeat new password field<br>"; } else { $repeatNewPass = mysqli_real_escape_string($con, $_POST['repeatNewPass']); // check to make sure that $newPass and $repeatNewPass matches if($newPass != $repeatNewPass){ $errorPass .= "Your new passwords does not match<br>"; } } // hash the password, before testing it against the DB function protect_pass($val) { return md5($val); } if(empty($errorPass)){ $pass_hash = protect_pass($oldPass); // check to make sure their old password is correct $sql = "SELECT password FROM register WHERE password='$pass_hash'"; $query = mysqli_query($con, $sql); $numrows = mysqli_num_rows($query); if($numrows < 1){ $errorPass .= "Your old password is not correct<br>"; } else { $pass_hash = protect_pass($newPass); $sql = "UPDATE register SET password='$pass_hash' WHERE u_name='$log_username'"; $query = mysqli_query($con, $sql); if($query == true){ $successPass = "Your password has been changed<br>"; } else { $errorPass .= "Some unexpected error occured while trying to change your password<br>"; } } }
  17. I want to check the type of a variable but when i do this $test = "hi";$var = var_dump($test);or$var = print_r($test); It outputs the content, but i dont want that.
  18. Why does my jQuery slideDown() function slide my div up? here is the div that is supposed to get slided down $statuslist .= '<br><br><br><br> <div class="toggleMsg">msg</div> <div> <div id="status_'.$id.'" class="status_boxes"><div style="background: yellow;"><b>Sent from <a href="user.php?u='.$sender.'">'.$sender.'</a> '.$date_sent.':</b> '.$statusDeleteButton.' <br /></div>'.$status_replies.'</div>'; $statuslist .= '<textarea id="replytext_'.$id.'" class="replytext" onkeyup="statusMax(this,250)" placeholder="write a reply here"></textarea><button id="replyBtn_'.$id.'" onclick="replyToStatus('.$id.',''.$log_username.'','replytext_'.$id.'',this)">Reply</button> </div>'; You may not see it, but right next to the div with class="toggleMsg" there is another div that wraps all of the other content, so that jQuery will select the div right next to it. here is the css style for everything inside $statuslist <style type="text/css"> /*style the conversation field*/ textarea#statustext{width:982px; height:80px; padding:8px; border:#999 1px solid; font-size:16px;} div.status_boxes{padding:12px; line-height:1.5em;} div.status_boxes > div{padding:8px; border:#99C20C 1px solid; background: #F4FDDF;} div.status_boxes > div > b{font-size:12px;} div.status_boxes > button{padding:5px; font-size:12px;} textarea.replytext{width:98%; height:40px; padding:1%; border:#999 1px solid;} div.reply_boxes{padding:12px; border:#999 1px solid; background:#F5F5F5;} div.reply_boxes > div > b{font-size:12px;} </style> Here is the jQuery style for the div with class="toggleMsg" $(document).ready(function() { // trigger the function when clicking on an assigned element $(".toggleMsg").click(function () { // check the visibility of the next element in the DOM if ($(this).next().is(":hidden")) { $(this).next().slideDown("slow"); // slide it down } else { $(this).next().hide("slow"); // hide it } });});
  19. I have a script here that is supposed to select information from 2 databases, but it only select from one, conversation_message. $status_replies = ""; // select all the replies connected to their specific thread $sql = "SELECT conversation_message.id, conversation_message.subject, conversation_message.message, conversation_message.date_sent, conversation.sender FROM conversation_message LEFT JOIN conversation ON conversation_message.id = conversation.id ORDER BY conversation_message.date_sent ASC"; $query_replies = mysqli_query($con, $sql); $replynumrows = mysqli_num_rows($query_replies); if($replynumrows > 0){ while ($row2 = mysqli_fetch_array($query_replies, MYSQLI_ASSOC)) { $statusreplyid = $row2["id"]; $statusReplySubject = $row2["subject"]; $replydata = $row2["message"]; $statusReplySender = $row2["sender"]; $replydata = nl2br($replydata); $replydata = str_replace("&","&",$replydata); $replydata = stripslashes($replydata); $replyDate = $row2["date_sent"]; // holds all of the replies $status_replies .= '<div id="reply_'.$statusreplyid.'" class="reply_boxes"><div><b>Reply by <a href="user.php?u='.$statusReplySender.'">'.$statusReplySender.'</a> '.$replyDate.':</b><br />'.$replydata.'</div></div>'; } } $statusReplySender which comes from the conversation table dont return anything, and yes it does have a value inside the DB.
  20. for example _(success).innerHTML = 'All of you messages has now been deleted'; wont trigger, its supposed to target the <span> with id of "success"
  21. I have created a button that is supposed to delete all of your messages inside the DB if(!$numrows >= 1) { $error = "You have no messages in your inbox<br>"; } else { $deleteAll = " <button onmousedown='askFirst()'>Delete all messages</button> "; while ( $row=mysqli_fetch_array($query) ) { $id = $row['id']; $reciever = $row['reciever']; $sender = $row['sender']; $date_sent = $row['date_sent']; $message = $row['message']; $subject = $row['subject']; $msgDeleteButton = ''; // gives the author of the comment, or the page owner the ability to delete the reply if($sender == $log_username){ $msgDeleteButton = '<span><a href="#" onclick="return false;" onmousedown="deleteMsg(''.$id.'','sent_'.$id.'');" title="DELETE THIS MESSAGE">remove</a></span>'; } // holds all of the replies $status_replies .= '<div id="sent_'.$id.'" class="sent_message"><div><b>Sent by '.$sender.' '.$date_sent.':</b> '.$msgDeleteButton.'<br />'.$message.'</div></div>'; } } The function the "button" calls "askFirst()" is here: function askFirst(){ $answer = alert("Are you sure you want to delete all of your messages?"); if ($answer != true) { return false; } var ajax = ajaxObj("POST", "php_parsers/status_message.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) == true) { if(ajax.responseText == "delete_ok"){ _(success).innerHTML = 'All of you messages has now been deleted'; } else { alert(ajax.responseText); } } } ajax.send("action=delete_all_msg"); } They are on the same page: sentMsg.php also in my editor "komdo", there is a green underline under "function askFirst()" says that askFirst() doesnt always return a value. I dont think that it matters as i tried to comment out if($answer != true){ return false; } Then suddently the green underline disapeared. The AJAX makes a call to php_parsers/system_message.php. Which is here: if (isset($_POST['action']) && $_POST['action'] == "delete_all_msg") { $sql = "UPDATE conversation SET deleted='1' WHERE sender='$log_username'"; $query = mysqli_query($con, $sql); echo "delete_ok";}
×
×
  • Create New...