Jump to content

gergy008

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by gergy008

  1. Dude you're a star, I completely forgot about those things, I need to back to lesson zero XD thanks!
  2. Maybe this might come in handy: http://pdfobject.com/
  3. Uhm... this is the PHP help... not the Javascript help. Only a handful of the guys here specialise in jQuery.
  4. Change return (!isset($_SESSION['token']) || $this->_token != $_SESSION['token']) ? 0 : 1; to return (!isset($_SESSION['token']) || $this->_token != $_SESSION['token']) ? 1 : 0; And see what happens
  5. Hey everyone! It's been a while ^^ So I've run into a regex problem, it was never my strong point tbh, however, I've come across an issue I can't seem to find a solution to Basically I'm using the following regex to check if a password meets the requirements, which are: Contains a letter Contains a number Can use only A to Z, a to z, 0 to 9 and any of these in the password too:!@#$%. What's going on? Heres line 81, and the error I'm getting. elseif(preg_match('^(?=.*\d+)(?=.*[A-z])[0-9A-z!@#$%]$', $pwds['pwd'])!=1) $problems['pwd']='Passwords must contain one letter and number. Also allowed: .!@#$%'; A PHP Error was encountered Severity: Warning Message: preg_match(): No ending delimiter '^' found Filename: controllers/daemon.php Line Number: 81 Thanks! Gergy.
  6. sesseion_start(); On the first of the other pages. I don't know if this effects anything but I just spotted it.
  7. Hi, I managed to source this code that allows me to work out how many days until a date. However I don't know how it works so I can't change it to make it work out months. Can someone kindly help me understand it? Also this code uses the unix timestamp system. $cdate = $deadlinedate; $today = time(); $difference = $cdate - $today; if ($difference < 0) { $difference = 0; $days=floor($difference/60/60/24); All help appreciated. Thanks in advance.
  8. Haha, Thanks, I just realised. It was intended to be an example though but yeah I suppose.
  9. Thanks for your reply, I completely forgot about the logs. The log is saying there is a parse error, I found it and fixed it. I can't believe I missed a semi-colon on line 158, Yet when I take the code hinted out it works fine, No errors thrown. Very weird. I got it fixed, Thanks for taking your time to read!
  10. I would tend to use the MD5 function to generate random characters $str1=substr(md5(rand()*rand()/rand(), rand(1, 20), 4); $str2=substr(md5(rand()*rand()/rand(), rand(1, 20), 4); $str3=strtoupper($str1."-".$str2);
  11. Okay, I have no idea how this works out but this is really getting on my nerves. Here is my logic for the following code. I manually register a user, It goes into the database and dispatches an email notification explaining that a user must activate their account and change their user name (OPTIONAL) and password. In the email, There is an automatically generated password with the username, And a link to activate the account. This leads to stage 1 of the activation process, In this stage the user is accepted, Registered as a verified user and then is sent to another page to change the details like login and password. As far as I know this page works except through trial and error I found that this little snippet of code is causing browsers to show an error 500 page, If I remove this the page works: <?php if($messages){ displayErrors($messages); } else { echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); } ?> and this is the displayErrors function: <?php function displayErrors($messages) { print("<p align=\"center\" class=\"standard\">"."<b>There were problems with the previous action:</b>\n<ul>\n"); foreach($messages as $msg){ print("<li>$msg</li>\n"); } print("</ul>\n"."</p>"); } ?> The displayErrors function is in a file called functions.php, Which is included in config.php, Which is included in every page including this one. The entire "Change password and login page thingie" is here: <?php include("config.php"); global $link, $messages; require_once('recaptchalib.php'); if($_GET['error']){ $id=$_GET['id']; $messages[]="There is more than one or no accounts with the verification code you are using. <a href=\"mailto:rentals@nivso.co.uk?subject=Two or no accounts with activation ID of $id\">Click here to email us about this and have the problem sorted.</a>"; doIndex(); exit; } if(isset($_POST['submit'])){ if(!isset($_POST['activationid'])){ die("Doesn't exist -.- might as well quit this is *STUFF* -.-"); } $privatekey = "YOUR NOT HAVING THIS"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $messages[]="The code you entered is incorrect. Please go back and try again!"; doIndex(); exit; // exit or the below lines will be processed. } else { //This is where the fun starts! $login=$_POST['login']; $passw=$_POST['password']; $passc=$_POST['passwordc']; $id2=$_POST['activationid']; $changinglogin=false; $get1=excDB("SELECT * FROM `users` WHERE `activeID`='$id2'"); if($get1[0]){ $get1=$get1[1]; } else { die($get1[2]); } $pro1=mysql_fetch_array($get1); if($pro1['login']!=$login){ $changinglogin=true; field_validator("Login", $login, "alphanumeric", 4, 15); } field_validator("Password", $passw, "string", 6, 20); if($passw!=$passc){ $messages[]="The passwords do not match, Please make sure that the passwords are the same!"; } if($messages){ doIndex(); exit; } $passcl=mysql_escape_string($passw); $passen=md5($passcl); if($changinglogin){ $wri1=excDB("UPDATE `users` SET `login`='$login', `password`='$passen', `passchange`='1', `loginchange`='1' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created"); } else { $wri1=excDB("UPDATE `users` SET `password`='$passen', `passchange`='1', `loginchange`='0' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created2"); } } } else { doIndex(); } function doIndex(){ ?> <!DOCTYPE html> <head> <title>Family Rental System! - Rent your DVDs here - Design by Alex, Coding by Gergy008</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" href="css/main.css" rel="stylesheet"> <style type="text/css"> <!-- body { background-color: #333333; } --> </style></head> <body style="text-align:center;"> <div class="first"> <div class="backgrounder1"></div> <div class="headerbar1"></div> <div class="headerbar2"></div> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="900"> <tr> <td><img src="images/spacer.gif" width="52" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="123" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="352" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="33" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="55" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="50" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="15" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.1.png"> </td> <td><img src="images/spacer.gif" width="1" height="20" border="0" alt="" /></td> </tr> <tr> <td colspan="5" background="images/template.slice.2.png"> </td> <td colspan="2" rowspan="2" background="images/template.slice.3.png"><span class="login"><?php echo(loginHandler()); ?></span></td> <td colspan="2" rowspan="3" background="images/template.slice.4.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td rowspan="8" background="images/template.slice.5.png"> </td> <td colspan="2" background="images/template.slice.6.png"><form> <div align="center"> <input name="textfield" type="text" id="textfield" size="40" style="height:16px;"> <input type="submit" name="button" id="button" value="Search" style="height:20px;"> </div> </form></td> <td colspan="2" rowspan="2" background="images/template.slice.7.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="2" rowspan="3" background="images/template.slice.8.png"><p> </p> <p> </p></td> <td colspan="2" background="images/template.slice.9.png"> </td> <td><img src="images/spacer.gif" width="1" height="70" border="0" alt="" /></td> </tr> <tr> <td rowspan="2" background="images/template.slice.10.png"> </td> <td colspan="4" background="images/template.slice.11.png"> </td> <td rowspan="6" background="images/template.slice.12.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.13.png"></td> <td><img src="images/spacer.gif" width="1" height="8" border="0" alt="" /></td> </tr> <tr> <td rowspan="4" background="images/template.slice.14.png"> </td> <td colspan="4" background="images/template.slice.15.png"> </td> <td colspan="2" rowspan="4" background="images/template.slice.16.png"> </td> <td><img src="images/spacer.gif" width="1" height="35" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.17.png"> </td> <td><img src="images/spacer.gif" width="1" height="37" border="0" alt="" /></td> </tr> <tr> <td colspan="4" align="center" valign="top" background="images/template.slice.18.png" style="vertical-align:top;"><p class="standard"> </p> <table width="80%" border="0"> <tr> <td colspan="2"> <?php if($messages){ //displayErrors($messages); } else { //echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); ?></td> </tr> <form name="ChangeDetails" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="hidden" name="activationid" value="<?php if($_GET['id']){ $id=$_GET['id']; echo($id); } elseif($_POST['activationid']){ $id=$_POST['activationid']; echo($id); } else { die("No ID") } ?>" /> <tr> <td width="50%"><div align="right" class="standard">New Username: </div></td> <td width="50%"><input name="login" type="text" id="login" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">New Password:</div></td> <td><input name="password" type="password" id="password" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Re-enter password:</div></td> <td><input name="passwordc" type="password" id="passwordc" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Please enter the code: </div></td> <td> <?php require_once('recaptchalib.php'); $publickey = "6Le4fsESAAAAAKMOHb8aaiyDfGRJyr0y0EU7dXm-"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Change your details" /></td> </tr> </form> </table> </td> <td><img src="images/spacer.gif" width="1" height="450" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.19.png"> </td> <td><img src="images/spacer.gif" width="1" height="50" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.20.png"> </td> <td><img src="images/spacer.gif" width="1" height="40" border="0" alt="" /></td> </tr> </table> </div> </body> </html> <?php } ?> Thanks to all you kind people that take your time to read and help me with this problem. I'm sorry if it is a really simple problem I missed out that makes me look like a right idiot and wasted your time, but that's me I'm always missing stuff out like that, I do proof read though just sometimes not good enough. Thanks in advance!
  12. My bad it was, And I found some code, I was looking for something like this: <?php function Truncate($string, $length, $stopanywhere=false) { //truncates a string to a certain char length, stopping on a word if not specified otherwise. if (strlen($string) > $length) { //limit hit! $string = substr($string,0,($length -3)); if ($stopanywhere) { //stop anywhere $string .= '...'; } else{ //stop on a word. $string = substr($string,0,strrpos($string,' ')).'...'; } } return $string; } ?>
  13. But that will cut some strings half way though a word, And won't give me the ... at the end, I seen it somwhere but I can't remember the name is it truncation or something?
  14. I don't know if this will help but your setting variables before you cave made the array with mysql_fetch_array. Try using this: <?php require('header.php'); mysql_select_db('center'); $sql = "select username, password from users"; $result = mysql_query($sql); echo "<table border='1'>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>$row['username']</td>"; echo "<td>$pass['password']</td>"; //Remeber this is a loop so every time it passes through each row it gets a new username and password, Opposed to you echoing the first line before. echo "</tr>"; } echo "</table>"; ?>
  15. So I just echo that and it works? Sweet, Rather simple [/latepost]
  16. Hi guys, What is it called when you have a long paragraph shoretend, With php of course, To make it like haljh;lajbsdg... For example, I have this paragraph: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus placerat consequat enim, pretium viverra massa cursus nec. Sed in pharetra magna. Aliquam egestas vehicula mi, sed pellentesque ligula suscipit a. Donec lectus velit, luctus sed lobortis vitae, sollicitudin in sem. Ut facilisis, velit in accumsan porttitor, libero neque molestie leo, ac vulputate eros libero eget mauris. Ut nec justo augue. How to I make it so PHP detects if it is too long and trims it down like: Lorem ipsum dolor sit amet, consectetur adipiscing elit... If I can find what this is called then I can google it to find it and use it on my site. Thanks in advance!
  17. Got it sorted, Adding tags for google search results and heres the code. Very simple $dobs=explode("/", $dob); $newdob=$dobs[2].$dobs[1].$dobs[0]."000000"; //converts 21/02/1995 into 19950221000000 so you can directly compare with other dates in the format date("ymdhis")
  18. I'm having trouble with this emailing script. As you can see it clearly sets the contect typw to text/html but when you read the email it's not in HTML like intended $to=$email; $subject='Activate your account.'; $message=" <html> <head> <title>Activate your account that doesn't show in HTML damn it -.-</title> </head> <body> <p>Nothing here.</p> </body> </html> "; // To send HTML mail, the Content-type header must be PROPERLY set $headers = 'MIME-Version: 1.0' . '\r\n'; $headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n'; // Additional headers $headers .= 'To: $fname <$email>' . '\r\n'; $headers .= 'From: **************' . '\r\n'; $headers .= 'Reply-To: ******************' . '\r\n'; $headers .= 'X-Mailer: PHP/' . phpversion(); // Mail it $mail=mail($to, $subject, $message, $headers); Can someone help me solve why it's sending as plain text and not HTML this is getting annoying Thanks in advance,
  19. But I need it also to be user friendly, So the datepicker creates dd/mm/yyyy but php converts it to yyyymmdd I'll try it like that PFMa, I didin't think it would work but I just didn't think about it right.
  20. Hello everyone, I'm here again with moar problems . This time I need help converting dates, I have the jQuery UI Datepicker on my register form, Which creates a date with the format of 21/02/1995, Or "dd/mm/yyyy". Can someone explain how convert this string to "yyyymmdd"? Thanks in advance (Something tells me this will end up really simple.... Hmm......)
  21. The issue here is I don't know how to make it work how I described, How to open a jQuery UI Dialog through PHP. Sounds easy but I'm still learning like. Thanks.
  22. When ever I try to google this I always get it the other way round "Calling PHP from jQuery" which is now what I need. Basically I want, When the script starts, For PHP to check if an array is empty and if it's not call a jQuery function (This would be the jQuery UI Dialog box). If you can help me here or even post a link to a resource then I will kiss ya. No homo. Thanks in advance!
  23. Thanks, I forgot to mention that read_file() is a custom function function read_file($filename) { $f=fopen($filename,"r"); $data=fread($f,filesize($filename)); fclose($f); return $data; }
  24. <?php //Connect to the database prior to this code ?> <table width="200px" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="33%" align="center" bgcolor="#00005F"><strong>col</strong></td> <td width="33%" align="center" bgcolor="#00005F"><strong>col2</strong></td> <td width="33%" align="center" bgcolor="#00005F"><strong>col3</strong></td> </tr> <?php $sql="SELECT `col`, `col2`, `col3` FROM `table` WHERE 1=1;"; //Change the 1=1 to why you want to pull from the database because of. $result=mysql_query($sql, $link); while($rows = mysql_fetch_array($result)){ ?> <tr> <td <?php echo $rows['col']; ?></td> <td <?php echo $rows['col2']; ?></td> <td><?php echo $rows['col3']; ?></td> </tr> <?php } ?> </table>
×
×
  • 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.