etsted
-
Posts
274 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by etsted
-
-
jquery
in JavaScript
It says in w3schools.com that you should use document.write
-
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); }?>
-
widegrass.com
-
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
-
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>
-
-
Don't name your function delete, delete is an operator in Javascript. Also, check the HTML that gets printed in the browser for syntax errors with that line.
That was my problem
-
if you tried my script out maybe you could see something wrong from there.
-
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;}
-
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>
-
did anyone figure it out? why does my jQuery slidedown() function, somehow slide my div up again?
-
I think i fixed it
-
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>
-
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>"; } } }
-
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.
-
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 } });});
-
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.
-
for example
_(success).innerHTML = 'All of you messages has now been deleted';
wont trigger, its supposed to target the <span> with id of "success"
-
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";}
-
I cant see anything wrong here, but when i try to echo the $id variable i get nothing, i have tried with some of the other variable but i get nothing. I also have a custom $error variable that is supposed to tell me if i dont have anything i the DB, and it keeps saying that i dont.
// if the user is not logged in, header them away if($user_status != true) { //header("location: index.php"); } $error = $sentMsg = $status_replies =""; // select all of a users messages from the DB //$sql = "SELECT id, to, from, date_sent, message, subject FROM conversation WHERE `from`='$log_username' AND deleted='0' "; $sql = "SELECT * FROM conversation"; $query = mysqli_query($con, $sql) or die(mysqli_error($con)); // check to see if he has more than 1 message $numrows = mysqli_fetch_array($query); if($numrows > 0) { $error = "You have no messages in your inbox<br>"; } else { while ( $row=mysqli_fetch_array($query) ) { $id = $row['id']; $to = $row['to']; $from = $row['from']; $date_sent = $row['date_sent']; $message = $row['message']; $subject = $row['subject']; $sentMsg = " <form action='' method='post' name='msgForm_".$id."'> <input type='checkbox' name='box_".$id."'> </form> "; } echo $id; }
-
got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to, from, date_sent, message, subject FROM conversation WHERE `from`='jacop' AND' at line 1
while trying this:
$sql = "SELECT id, to, from, date_sent, message, subject FROM conversation WHERE `from`='$log_username' AND deleted='0' ";
-
Can someone tell me whats wrong with this code? I just cant see it
$sql = "SELECT * FROM conversation WHERE from='$log_username' AND deleted='0' ";
error caused: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from='jacop' AND deleted='0' '' at line 1
-
did you even apply any changes?
-
so i echoed $sql, and it did what i wanted it to do. I also runned the mysqli_error($con) and had no errors. Then i try to run the script but it wont work. I have also changed the script a little
"SELECT conversations.conversation_id, -- gets the id from conversations table conversations.conversation_subject, -- gets the subject from conversations table MAX(conversation_messages.message_date) AS 'conversation_last_reply', -- gets the latest message posted from conversation.message MAX(conversation_messages.message_date) > conversation_members.conversations_last_view AS 'conversation_undread' -- gets all the messages that has a "date value" greater than the users "last view" date value FROM conversations -- select the values from the conversations table LEFT JOIN conversation_messages ON conversations.conversation_id = conversation_messages.conversation_id -- also select the values from conversation_messages INNER JOIN conversation_members ON conversations.conversation_id = conversation_members.conversation_id -- also select the corresponding values from conversation_members WHERE conversation_members.user_id = 1 AND conversation_members.conversation_deleted = '0' -- select all messages that a user hasnt deleted GROUP BY conversations.conversation_id ORDER BY conversation_last_reply DESC";
What ways are there to "delete" elements
in JavaScript
Posted · Edited by etsted
I know you can use javascript to hide elements, as a "delete option", but is that really the only way, or the most effecient?