Jump to content

cozzy1984

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cozzy1984's Achievements

Member

Member (2/5)

0

Reputation

  1. Just wondering if anyone knows a simple way to disable magic quotes. I have my site uploaded onto freehostia and ive run a check to see if they are enabled and it brought back: magic_quotes_gpc = 1 register_globals = 1 I cant see any settings to turn off on the site manager, and i have this code: php_flag magic_quotes_gpc off but do i put this code in its own file or where do i put it? Hope someone can help. Cheers
  2. Don't worry about this, managed to get it working.
  3. Hi there, I'm looking to compare a timestamp that was automatically created by the mysql database when each record was created with todays date. Firstly i believe i have to get it into the same format tho and was looking for pointers on how to do this. Currently if i echo the value of the timestamp in one of the database records it reads: 2008-02-15 15:31:14 Been looking around but haven't had much luck on this, so wondering if you guys could help. Cheers
  4. Cheers lads, i now have when adding the advert: $description = nl2br($_POST['description']); and when displaying it my code is: echo "<td colspan='2' height='60' valign='top'>".substr($description,0,150). "...</td>"; Which limits the character count to 150 i think and then puts ... at end. I would prefer this to stop at word count rather than character count as it can stop in middle of a word, if anyone new code for this i would appreciate it. However it still can be ruined by someone typing a contiuous long word, as it'll make the table long and upset the whole design.
  5. Hi, just a quick question. I've got a description field on a form and have it to inserted into a text mysql field. Problem is when i am displaying the data in a table with an echo statement. It doesn't output i the same way it was typed in. For instance it doesn't take new lines when i had done so we typing into the textarea. Is there a better way of doing this, possibly storing it as some other type in the database. Also there is a problem in that if the user typed in a long continuous word without spaces, it makes the table i am displaying them in really wide and ruins the design. Is there a way round this also? Would appreciate any ideas.
  6. Hi, just found a useful script that im looking to modify for uploading and creating a thumbnail of an image. $size = 80; // the thumbnail height $filedir = 'pics/'; // the directory for the original image $thumbdir = 'pics/'; // the directory for the thumbnail image $prefix = 'small_'; // the prefix to be added to the original name $maxfile = '2000000'; $mode = '0666'; $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $userfile_type = $_FILES['image']['type']; if (isset($_FILES['image']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[1]/$sizes[0]; if ($sizes[1] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; }else{ $new_height = $size; $new_width = abs($new_height/$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or $error['image'] = 'Problem in creating image'; $imageerror = 'regerrorwrong'; $srcimg=ImageCreateFromJPEG($prod_img) or $error['image'] = 'Problem in opening source'; $imageerror = 'regerrorwrong'; if(function_exists('imagecopyresampled')) { imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or $error['image'] = 'Problem in resizing'; $imageerror = 'regerrorwrong'; }else{ Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or $error['image'] = 'Problem in resizing'; $imageerror = 'regerrorwrong'; } ImageJPEG($destimg,$prod_img_thumb,90) or $error['image'] = 'Problem in saving'; $imageerror = 'regerrorwrong'; imagedestroy($destimg); } I have the code working now uploading the path of thumbnail and path of image to my databse, although now am looking to modify the creating thumbnail code a bit. I am looking basically to know if there is a simpler way of doing it than above, and also how to incororate gifs and maybe png files but produce error on other file types. At the moment if i try to upload for example a txt file it produces a lot of warning error messages: Warning: Division by zero in C:\wamp\www\Adll Do\editaddvert.php on line 169 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\wamp\www\Adll Do\editaddvert.php on line 180 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\wamp\www\Adll Do\editaddvert.php on line 182 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'pics/wireless.txt' is not a valid JPEG file in C:\wamp\www\Adll Do\editaddvert.php on line 182 Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\Adll Do\editaddvert.php on line 186 Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\Adll Do\editaddvert.php on line 186 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\Adll Do\editaddvert.php on line 186 Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\wamp\www\Adll Do\editaddvert.php on line 192 Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\Adll Do\editaddvert.php on line 194
  7. Was just wondering whats the best way to have 2 select boxes, with the options in the 2nd one being affected by that selected in the first. Is ajax the best way, and is there any simple scripts or examples that anone knows of. Would be very helpful. Cheers
  8. Sorry, i do have the = but it doesn't work with it. How do u change the type to text/html asch? I have: $mail = new PHPGMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = 'ssl://smtp.gmail.com'; // SMTP servers $mail->Username = '*****@gmail.com'; $mail->Password = '******'; $mail->From = '*****@gmail.com'; $mail->FromName = 'test'; $mail->Subject = 'test Registration'; $mail->AddAddress($email); $mail->Body = "Your account has been successfully created with the following details:\n\nUsername: $username\nPassword: $password\nEmail: $email\nForename: $forename\nSurname: $surname\nLocation: $location\n\nPlease click on the link to activate your account.\n"; $mail->Body .= "<a href='http://localhost/Ad'll%20Do/activate.php?username=$username&&do=$active_code'>Activate Account</a>";
  9. Hi there, just managed to get a email activation working although the only problem i'm having is actually displaying the url link in the email. It is only outputting it as text and not a clickable link. Know this is probably really simple but, would really appreciate if someone could show me how to. My code is: $mail->Body = "Your account has been successfully created with the following details:\n\nUsername: $username\nPassword: $password\nEmail: $email\nForename: $forename\nSurname: $surname\nLocation: $location\n\nPlease click on the link to activate your account.\n<a href'http://localhost/Ad'll%20Do/activate.php?username=$username&&do=$active_code'>Activate Account</a>";
  10. Actually managed to somehow get my email working so that it send an email with their registration details when they signup. Now im looking to do an account activation with the email, making it send out a unique url for them to click. Read about using the users password and a timestamp to create the url, however it didnt go into much detail. It said to create a field with a timestamp and use the time() to insert the timestamp into this, the encode it in the url with the users password. Thing is, when i use the $t = time(); and then try to insert the $t into the tablle it comes up always as 0000-00-00 (and the rest all 0's). Just wondering is there anyone who could help me on this matter, ot even suggest a better way for account activation if this doesn't seem the best option. Cheers
  11. Am trying to pull the md5 password from the database and make sure that it is the same as what they entered into a input box, to confirm the password before they change it to a new one. Have it working using the seesion variables at the minute instead but would like it working by getting the values from the database rather than the session variables.
  12. Cheers revraz, but that didn't help. I printed out both the $md5passwordold and the $account['password'] and they are the same so i dont understand why this isnt working but am pretty sure it may be down to the fact that i am using $account['password'] to compare in the if statement as the one that compares that the password doesnt eaual $account['username'] is also not working. Is there a special way when using values from a mysql query in an if statement?
  13. Having a bit of trouble when trying to check if an input string (password) equals the md5 password in the database table. Thought best way to do it was to make the string into an md5 variable (md5passwordold) and compare them both. But for some reason it doesnt seem to work. Heres a snippet of my code: <?php if (isset($_POST['submit'])) { $password = $_POST['password']; $newpassword = $_POST['newpassword']; $newpassword2 = $_POST['newpassword2']; $md5passwordold = md5($_POST['password']); $md5password = md5($_POST['newpassword']); if($password && $newpassword && $newpassword2) { if($md5passwordold != $account["password"]) { $error['password'] = 'Incorrect Password'; $passworderror = 'regerrorwrong'; } if($newpassword != $newpassword2) { $error['newpassword'] = 'Passwords don\'t match'; $newpassworderror = 'regerrorwrong'; } else if($password == $account["username"]){ $error['newpassword'] = 'Can\'t be same as username'; $newpassworderror = 'regerrorwrong'; } else if (preg_match( '/\W/', $newpassword) || !ctype_alnum($newpassword)){ $error['newpassword'] = 'No spaces / Invalid characters'; $newpassworderror = 'regerrorwrong'; } } else { $error['password'] = 'Please complete all fields'; $passworderror = 'regerrorwrong'; } } if(!$_SESSION["username"]){ ?> <div id='postit'> <div id='scotchtape'> </div> <h2>Not Logged In!</h2> <p><span class='highlight'>Sorry, you are not logged in, therefore unable to view this page.</span> Please try logging in using the form on the right. If you are not a member you can register for free <a href="register.php">here..</a></p> </div> <?php } else if (!$error && isset($_POST['submit'])) { $update = mysql_query("UPDATE users SET password='$md5password' WHERE username='" . $_SESSION["username"] . "'"); ?> <div id='postit'> <div id='scotchtape'> </div> <h2>Password Change Successful</h2> <?php echo "<p><span class='highlight'>Your password has been successfully updated " . $_SESSION["username"] . "</span>";?> <p>Please Logout in order to test your new password, if there are any problems please contact us.</p> </div> <?php } else{ $account = mysql_fetch_array(mysql_query("SELECT username,password FROM users WHERE username='" . $_SESSION["username"] . "'")); ?> <div id='postit'> <div id='scotchtape'> <img src='images/scotchtape.png' alt='' height='41' width='100' /> </div> <h2>Change Password</h2> <p><span class='highlight'>Below are the details for your account, <?php echo $account["username"]; ?></span><br/>You can edit your details simply by changing them and clicking the save changes button.</p> <div id="helpicon"><img src='images/help_icon.png' alt='' height='70' width='70' /></div> <div id="directionstitle">Help Information</div> <div id="directions">This box will contain help relating to each section.<br/> All fields are required.</div> </div> <form name="registration" method="post" class="regform" action="" enctype="application/x-www-form-urlencoded"> <fieldset> <label for="password">Current Password:</label> <input name="password" type="password" id="password" maxlength="15" value="<?php echo $_POST['password']; ?>" onfocus="infotitle('Enter Curent Password'); info('Please enter your current password to authenticate user.');" /> <span class="<?php echo $passworderror; ?>"><?php echo $error['password']; ?></span> </fieldset> <fieldset> <label for="newpassword">New Password:</label> <input name="newpassword" type="password" id="newpassword" maxlength="15" value="" onfocus="infotitle('Re-Enter Password'); info('Your password can be any combination of characters and must be at least 4 chartacters in length.');" /> <span class="<?php echo $newpassworderror; ?>"><?php echo $error['newpassword']; ?></span> </fieldset> <fieldset> <label for="newpassword2">Re-Type New Password:</label> <input name="newpassword2" type="password" id="newpassword2" maxlength="15" value="" onfocus="infotitle('Re-Enter Password'); info('Please re-enter your new password to make sure it is correct.');" /> </fieldset> <input type="submit" class="savebtn" name="submit" value="" /> </form> <?php } ?> Hope you's can help.
  14. Thanks for all your help, that worked well 'The Little Guy'. Am still trying to learn PHP and am doing a website involving a lot of it for university so your help is much appreciated. Still don't know much about the security aspect of it all but would like to look into it more when i get time but think i'll be starting on getting php mailer set up and email registration and activation next. Is the code i am using very unsecure Wolphie?
  15. nice one, wasn't sure if i was able to refer to active =='0' saying it was from the query $q = "select password,active from users where username = '$username'"; Thought i might have to somehow put it into another variable. Altho in saying that it doesn't seem to be working the way I tried.
×
×
  • 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.