Jump to content

angel1987

Members
  • Posts

    63
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

angel1987's Achievements

Member

Member (2/5)

0

Reputation

  1. @Barand: Yes, actually its not a birthday, i just replaced the actual column name randomly to hide it. Thanks for all the information. @Cataiin: This query worked for me, thanks
  2. I have been searching on internet for quite a while now for the query, tried many but none work, so i am resorting to asking myself. I have a table column with type varchar that stores date in format mm-dd-yyyy. I need to fetch all records from this table with the dates within next 4 days (between today and next 4 days). Also, i am using mysqli prepared statements to fetch this record. Below is the query which i tried, it works but not accurately. if ($stmt = $mysqli->prepare("SELECT names FROM members WHERE birthdate - INTERVAL 4 DAY > NOW() AND gender = ?")) { The above query displays records with dates after 4 days from today. I tried changing combinations for + - > and < like i had no idea what i was doing but each combination gave funny results. Has anyone tried this or knows how to do it? Please help me with this query, thanks in advance for your help.
  3. I noticed a bug in my script and i have been searching a lot on internet since past few hours but i could not find any information or solution. The script runs fine, no errors, but the script does not fetch last row/entry. Example, if there are 3 rows in the table, my script only pulls 2 rows. If there are 10, then only 9 are fetched. Please help me find the bug. Here is my script... <?php $query = "SELECT * FROM members WHERE $condition_res ORDER BY id DESC LIMIT $startpoint, $limit"; $result_query = mysqli_query($mysqli, $query); while($row = @mysqli_fetch_assoc($result_query)) { $mid=$row["id"]; $member=$row["name"]; $gender= $row["gender"]; ?> <tr> <td><?php echo $mid; ?></td> <td><?php echo $member; ?></td> <td><?php echo $gender; ?></td> </tr> <?php } ?> Note: $startpoint and $limit variables are for Pagination. $condition_res is for search criteria.
  4. Hello All, I am creating an image sharing platform for our local community and i need to know if there is any standards for resizing images in PHP? I mean how does bigger image sharing websites like imgur, flickr, etc resize their images? Also, there are already many small PHP scripts/functions available on internet to generate thumbnails or resize images on the go or while uploading, but i am not sure if we can use those for a website focused solely on images, can we? I will have to resize larger dimension images into smaller images while maintaining its quality. I am also aware of ImageMagicks and GDLibrary So, can anybody guide me or give me some information or suggest me on how to go about it? Thanks in advance for advice.
  5. Hello all, I have been searching for hours on google for answer but i couldnt find anything. So i have this "edit your post" form which is a set of text fields, text area, radio buttons and two datepicker calendar fields. I am getting the data from the MySql table to display it in these form fields and the submit button will simply fire Update query. But the problem is that when i add datepicker JQuery to this form, it does not display any values in the text fields from database but only in textarea box. Below is the JQuery script that i am using... <link rel="stylesheet" href="css/themes/base/jquery-ui.css" /> <script src="js/jquery-1.9.1.js"></script> <script src="js/ui/jquery-ui.js"></script> <script> $(function() { $( "#datepicker" ).datepicker(); $( "#datepicker2" ).datepicker(); }); </script> This is the form that is supposed to display values from database table. When i remove the above Javascript, it works. And when i use the above script, it shows values as Undefined for all the textfields. <form name="frmPost" method="post" action=""> <table border="0" cellpadding="5" cellspacing="5"> <tr><td>Title : </td></tr> <tr><td><input type="text" name="txttitle" size="75" value="<?php echo $title; ?>"/></td></tr> <tr><td valign="top">Description : </td></tr> <tr><td><textarea name="txtdescription" rows="10" cols="75" ><?php echo $description; ?></textarea></td></tr> <tr><td>Listing End date : </td></tr> <tr><td><input type="text" name="txtenddate" value="<?php echo $enddate; ?>" id="datepicker"/></td></tr> <tr><td>Project Completion Dead line : </td></tr> <tr><td><input type="text" name="txtdeadline" value="<?php echo $deadline; ?>" id="datepicker2"/></td></tr> <?php if($ptype=='w') { ?> <tr><td> <input type="radio" name="txttype" value="w" checked> Web Based <input type="radio" name="txttype" value="s">Desktop Based </td></tr> <?php } else if($ptype=='s') { ?> <tr><td> <input type="radio" name="txttype" value="w">Web Based <input type="radio" name="txttype" value="s" checked>Desktop Based </td></tr> <?php } else { ?> <tr><td> <input type="radio" name="txttype" value="w">Web Based <input type="radio" name="txttype" value="s">Desktop Based </td></tr> <?php } ?> <tr><td><input type="submit" name="btnupdate" value="Update" class="button" /></td></tr> </table> </form> I need some help in fixing this.
  6. Thanks for the support teynon, i had already tried using your first fix but it didnt work but yes the problem was with the javascript. I was hashing the password by javascript before sending it to the PHP script but it seems that works only if your PHP processing script is on another file and not on the same page. So i removed onclick attribute from submit button and hashed the password using PHP and it worked perfectly.
  7. Hello all, i have a change your password feature on one of my websites. It works perfectly in FF and Chrome but it is not working in IE 8. I have used MySQLi prepared statements and the script is fairly straight forward. In IE 8 when i click on submit button, it kills the session and gives "you are not authorized to view this page message". So I need some help in solving it. Below is the HTML form. <form name="frmcp" method="post" action="#"> <table border="0" cellpadding="5" cellspacing="5"> <tr><td>Old Password</td></tr> <tr><td><input type="password" name="password" id="password" /></td></tr> <tr><td>New Password</td></tr> <tr><td><input type="password" name="txtpass1" /></td></tr> <tr><td>Confirm Password</td></tr> <tr><td><input type="password" name="txtpass2" /></td></tr> <tr><td><input type="submit" name="btncp" value="Change Password" class="button" onclick="formhash(this.form, this.form.password);" /></td></tr> </table> </form> Below is the PHP Script which is on the same page above the html open tag. <?php // Include database connection and functions here. include '../php/config.php'; include 'php/functions.php'; //Securely Start Session sec_session_start(); //Check if user is logged in or not if((login_check($mysqli) == true) && $_SESSION['usertype'] == 0) { $userid = $_SESSION['user_id']; // Check if the button was clicked or not. if(isset($_POST['btncp'])){ //Check if all fields are filled. if(isset($_POST['txtpass1']) && !empty($_POST['txtpass1']) AND isset($_POST['txtpass2']) && !empty($_POST['txtpass2'])){ $newpass = htmlspecialchars(strip_tags($_POST['txtpass1'])); $newpass = hash('sha512', $newpass); $newcpass = htmlspecialchars(strip_tags($_POST['txtpass2'])); $newcpass = hash('sha512', $newcpass); //Check if new password matches the confirm password or not. if($newpass == $newcpass){ $password = $_POST['p']; //Check if the old password entered is correct or not. if ($stmt = $mysqli->prepare("SELECT username, password, usertype, salt FROM active_users WHERE user_id = ? LIMIT 1")) { $stmt->bind_param('i', $userid); // Bind "$email" to parameter. $stmt->execute(); // Execute the prepared query. $stmt->store_result(); $stmt->bind_result($username, $db_password, $usertype, $salt); // get variables from result. $stmt->fetch(); $password = hash('sha512', $password.$salt); // hash the password with the unique salt. if($stmt->num_rows == 1) { if($db_password == $password) { //Hash the new password with a new randomly created salt. $new_random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); $new_db_password = hash('sha512', $newcpass.$new_random_salt); //Update new password in the table. if ($stmt = $mysqli->prepare("UPDATE active_users SET password = ?, salt = ? WHERE user_id = ?")) { // Bind the variables to the parameter as strings. $stmt->bind_param("ssi", $new_db_password, $new_random_salt, $userid); // Execute the statement. $stmt->execute(); // Close the prepared statement. $stmt->close(); } //Redirect if password was changed and ask the user to login again using new password. header('Location: error.php?error=5'); } else { $msg = 'Old password entered is incorrect.'; } } else { $msg = 'User Does Not Exist.'; } } } else { $msg = 'New Password and Confirm Password does not match.'; } } else { $msg = 'All fields are mandatory.'; } } ?> The problem appears to be in the line where PHP checks if the button was clicked or not or in the line where it checks if user is logged in or not. But it works in FF and Chrome, just not in IE 8.
  8. I have a web page that lets user upload their profile photo. The PHP script works, but sometimes it just wont upload the photo. It will even give you a success message that the image was uploaded but it wont add the filename to the database nor will it save the file on the server. If you keep trying to upload the same image for couple more times then it will work and upload the photo. So i need some help in debugging it. Where am i going wrong? I am also using this thumb_function.php file which i got from internet, it basically saves thumbnails in a seperate folder, it works fine. Here is the PHP script that i am using. // Check if the button was clicked or not and process the profile updation if(isset($_POST['btnphoto'])){ include('php/thumb_function.php'); $filename = $_FILES["txtphoto"]["name"]; $newfilename = sha1($userid.$email); $extension = substr(strrchr($filename,'.'),1); $newfilename = $newfilename.".".$extension; $allowedExts = array("jpg", "jpeg", "gif", "png"); if ((($_FILES["txtphoto"]["type"] == "image/gif") || ($_FILES["txtphoto"]["type"] == "image/jpeg") || ($_FILES["txtphoto"]["type"] == "image/png")) && ($_FILES["txtphoto"]["size"] < 1048576) && in_array($extension, $allowedExts)){ if ($_FILES["txtphoto"]["error"] > 0){ $msg = "Error: " . $_FILES["file"]["error"] . "<br>"; } else { $path="../photos/".$newfilename; // the path with the file name where the file will be stored, upload is the directory name. if(move_uploaded_file ($_FILES["txtphoto"]["tmp_name"],$path)){ if ($stmt = $mysqli->prepare("UPDATE student_profile SET photo = ? WHERE user_id = ?")) { // Bind the variables to the parameter as strings. $stmt->bind_param("si", $newfilename, $userid); // Execute the statement. $stmt->execute(); // Close the prepared statement. $stmt->close(); } $msg = 'Your Photo has been updated... '; } else { $msg = 'Failed to upload file Contact Site admin to fix the problem'; exit; } $file = $newfilename; $save = $file; $t_w = 100; $t_h = 100; $o_path = "../photos/"; $s_path = "../photos/thumbnails/"; Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path); } } else { $msg = 'File is of a wrong type or too heavy.'; } } Here is the HTML form code.. <form name="frmphoto" method="post" action="" enctype="multipart/form-data"> <table border="0" cellpadding="5" cellspacing="5"> <tr><td>Upload Profile Photo : </td></tr> <tr><td><input type="file" name="txtphoto" size="45"></td></tr> <tr><td><input type="submit" name="btnphoto" value="Update Photo"></td></tr> </table> </form>
  9. I am trying to submit a form, but the next page loads very late. So i was thinking to put a pre loader image or animated loading gif right after the form submission before the next page loads. I am not sure how to do that, please help.
  10. I basically wanted to scan an entire website to see if it has any adult content or not. So i wanted to use PHP to scan for links and pages.
  11. But how will screen scraping give all the links associated with that domain name on that website? I searched on google but every article talks about fetching a part of the content on a web page from the website. I think i need to do something like a xml site map generator where it crawls website and displays all the links. Any tutorial for that?
  12. I tried searching on google but couldn't find any relevant information, please redirect me to relevant source or help me with the code. I want to pass a domain name in text field which will be scanned and then the script will display entire site map. Not external links or links on a page. Sorry it is not easy for me to explain. Eg. if i pass abc.com Script will display abc.com/12/adn.php abc.com/asd/asd/ etc Whatever their url format is. All the links on that domain.
  13. I know the regular database connection, but this time i am provided with the SSH details. This guy game me the IP address of the database server to connect and 2 login details. SSH: Username and Password DB: Username and Password And i am using XAMPP for trying out the code. Is there any plugin i need to download for SSH connections? Could you please give me the connection snippet for SSH because i don't really know how to do that, i am also searching elsewhere on internet. Thanks in advance for help...
  14. Ok, i changed the column type to DATE TIME and also changed the format of date while entering into the database to ... date("Y-m-d H:i:s"); And it looks like it is working since the BETWEEN query is displaying the data. All this on my local test server, But on the live website there are already many user submitted entries, is there any way to work it out there?
  15. No, the table column is not of DATE TIME type, i had set it as text because when i do it, it stores the date value as 0000-00-00 00:00:00 and it also replaces the previously stored values of date into 0000-00-00 00:00:00. I may be going wrong, i think i need to set a correct format for $subon = date("F j, Y, g:i a"); do i? Can you please help me with it? And this may be a bit dumb to say but since its a PHP function for date and time, it should work whatsoever right? Thanks again,
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.