Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I see what you mean, for now I used get, like wildteen said about cutting down the variable names. but now that I know this about sessions, I am going to start using little packets of information, as session arrays. I am goign to start passing information around that way, I am always afraid to use sessions, because I am afraid there might be something that won't work right, or something.  So I am going to put some thought into it, and start using that in my future projects, and see how the outcomes turn out.
  2. Whether I use that right now or not, I am not sure, but the advice you gave me may prove invaluable.  So I always have a group of sessions for the user, so instead, I can create an array. like $_SESSION['userinfo'] = array( then create a inside the array for there username, email, ip address, last logged in date, and everything else.  Then if I have admin later I could do $_SESSION['admin'] = array then have all that in there then use temporary set's of session data for other things. So tehre would actually never be a need for get if this was true, so there has to be negatives to doing that, what negatives come with doing that, that you know of? if any. I like that idea
  3. Ok using regular expressions check for what you are looking for.  Which would be line breaks.  Then replace that with a <br /> so it appears that way in the browser(you can do this with new line to br. nl2br Then after that, also use regular expressions to check for occurences of words with rn or whatever problem you were having, make sure the text stays proper until output.
  4. regex? like str_replace, and other things??  That might work have you thought of that.
  5. Any site that carries a lot of information you notice you use a lot of state saving.  Sessions, cookies, get, post, all over the place.  The site I am doing, uses a lot of sessions, it uses a lot of posts, and alot of get's It comes down to certain areas, where I am chaining together a good number of variables. http://www.domainname.com/display.php?school=UPenn&category=Item&subcategory=Sporting%20Goods&postset=postset1 and at some points it might get even bigger, is this going to present a problem, I heard when it get's over 255 characters, then there's a problem, because some browsers can cut some of that off. That's under 100 all together, with all characters together including hte domain name, so I know this should be fine, but in the event, I get it 2-3 times longer than that(hasn't happened yet), what can I do, to prevent this, or what do I have to worry about with doing it like that.
  6. I checked permissions, that wasn't the problem. I noticed a few issues, I had some of the folders named wrong so I fixed those.  ANd it is not 100% pointing to the right path, I am using this code below, and below that is the error it's giving me. [code]<?php // file handling if ($_FILES['notefile']['name']) { $newfile = "/upload/notesandcheatsheets/".basename($_FILES['notefile']['name']); $newfiletemp = "{$_FILES[notefile][tmp_name]}"; if (file_exists($newfile)) { $errorhandler .= "The file already exists"; } if (!move_uploaded_file($newfiletemp, $newfile)) { $errorhandler .= "There was some sort of problem moving the file"; } }else { $newfile = "No file was uploaded"; $newfiletemp = "No file was uploaded"; } // end file handling ?>[/code] Here is the error message below [quote]Warning: move_uploaded_file(/upload/notesandcheatsheets/access information.txt): failed to open stream: No such file or directory in /home/content/b/c/h/bcharnas/html/processors/post4.php on line 272 Warning: move_uploaded_file(): Unable to move '/tmp/php4SyVSd' to '/upload/notesandcheatsheets/access information.txt' in /home/content/b/c/h/bcharnas/html/processors/post4.php on line 272 There was some sort of problem moving the file [/quote]
  7. Ok I got it, but I am running into another problem. Here is my code for reference [code]<?php // file handling if ($_FILES['notefile']['name']) { $newfile = "./uploads/notesandcheatsheets/".basename($_FILES['notefile']['name']); $newfiletemp = "{$_FILES[notefile][tmp_name]}"; if (file_exists($newfile)) { $errorha ndler .= "The file already exists"; } if (!move_uploaded_file($newfiletemp, $newfile)) { $errorhandler .= "There was some sort of problem moving the file"; } }else { $newfile = "No file was uploaded"; $newfiletemp = "No file was uploaded"; } // end file handling ?>[/code] Ok there is the code, the problem I am having is it's not moving the file.  THe script that I am running for this is on a processor from the root folder it's from /processors/post4.php Now the file is being upload(from the root directory) to the following file /uploads/notesandcheatsheets/ for some reason it's not moving it, I am saving the newfile and newfiletemp variables into the database, the newfile being the url, and hte newfiletemp being the name. The thing is, it's not uploading, and I also need to make sure I can access the file later when calling the fileurl from the database.  So what do I need to do in this situation, and why isn't it working like this? Also for the newfile variable, where I am setting the url, I tried a few things I tried /uploads/notesandcheatsheets ./uploads/notesandcheatsheets but nothing seems to be allowing me to move the file.
  8. This isn't working, I want to test to see if they tried to upload a file, if they did, then I want to do some validation on the file, and then try to move it, check to make sure it exists, whatever.  BUt I only want to do that stuff if they tried to upload a file, because the file upload is optional, it's not required??  But when I test for the files variable before working on it, and don't upload a file, it still tries to work on the non-existent file, that would lead me to assume that the files array already has something stored in it, whether a file has been uploaded into memory or not, so how do I test to see if they attempted one.  because they can attempt an upload, and it not upload, so I still need to check for if (!is_uploaded_file) { $errorhandler .= "You file was not uploaded properly"; } that is one of the things I need to test for, but I don't want to test for that, unless they attempted to upload one and it failed, not jsut if they didn't want to upload one in the first place [code]<?php if ($_FILES) {     $newfile = "uploads/".basename($_FILES['file']['name']);     $newfiletemp = "{$_FILES[file][tmp_name]}";   if (file_exists($newfile)) {     $errorhandler .= "The file already exists"; } if (!move_uploaded_file($newfiletemp, $newfile)) { $errorhandler .= "There was some sort of problem moving the file"; } } ?>[/code]
  9. Nevermind, I wasn't sending it to the right table, nevermind.
  10. [code]$insert = "INSERT INTO $postinfo (categoryname, subcategoryname, schoolname, userid, coursenumber, title, author, price, zipcode, dateentered, expiredate) VALUES ('$category', '$subcategory', '$schoolname', '$userid', '$coursenumber', '$title', '$author', '$price', '$zipcode', '$dateentered', '$expires');";[/code] I have been re-using and re-replicating this sql query(with different variables), for over 4 days straight. A  total of 40 hours of work on this, and over 300 queries, and all of them worked fine, now out of nowhere I get one that says syntax error, right around category name, and I am sitting here comparing it to the other hundred and something queries and nothing is off, what's going on. It's for a classified ad system I am building for a client, everything else works, but when I got here, I noticed this one thing is messing up for some reason.
  11. I did that, and when i used today's date, it was today's it returned the date 1999-12-30
  12. I am recieving a date, formatted like mm-dd-yy so today would be like 9-18-06 How do I take that, and add 30 days to it, no matter what(also accounting leap year, and some months have less days than others.  Normally I just jump the month up one, but that won't work this time, it has to be 100% accurate, any advice.  I just need to hmm. Well I need to come up with a date in the future, so when  button is pressed it checks all the things in the database, and checks there date.  Any that are after the current date get deleted.  So if someone was posting ads 2-3 months ago, and the ads are there, and the admin clicks the button, any ones that were dated have already passed.  Like if it expired yesterday, or 2 days ago, or a week ago, then all the ones that are expired then get deleted automatically. so basically how do I add days to a date, take a formatted date, add a certain number of days to it, and get the date that it'll expire. Like if I post it today, I need to add 30 days to the date, I need to take todays date, add 30 days to it, and return the new date, so I can have that date as the expiration date.
  13. Ah, thanks, I will look and see my stylesheet, and replace error parts with what you have, I added a lot of styles for forms, and everything else, so I have to do that.  Thanks.  I was working on programming the past few days on it, I forgot about that, just finished the login system.
  14. I really don't feel that using sessions makes ajax, ajax does it.  Ajax, asynchronous javascript and xml, or text.  So using a text file, or .php file with information on it, but storing it in a session, what do you mean.  UNless you just store stuff in a session, like with php, like you normally do, but what do you mean with this.
  15. [code]SELECT * FROM `index` WHERE MATCH(title,description) AGAINST('$squery' IN BOOLEAN MODE) AS score FROM `index` WHERE MATCH(title,description) AGAINST('$squery' IN BOOLEAN MODE) ORDER BY score DESC LIMIT $from, $max_results[/code] not familiar with that, why not just use where statements WHERE something = '$something' instead of all of that?  order by, desc, those are standard, and limit, but this IN BOOLEAN MODE, I have never heard of it, or AGAINST, what are they.  WHERE MATCH,  MATCH(never heard of that).? could that be some of the problems.
  16. well I guess that will have to do, for the logout, I got it working with just [code]<?php session_start(); session_destroy(); header("location: /index.php"); ?>[/code] For my other page, I just settled for the, finish the process type of setup. [code]<?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php include './includes/meta.inc.php'; // includes meta tags, stylesheet, and javascript inclusion ?> </head> <body> <div id="wrap"> <?php include './includes/header.inc.php'; // inserts header, logo, and everything up there ?>     <br style="clear: both;" /> <?php include './includes/leftnav.inc.php'; // inserts left navigation ?>     <div id="content">         <div id="processor"> <h3>Sign Up Completion</h3> <?php // signing into database, and preparing for validation and entry mysql_connect("mysql185.secureserver.net", "#####", "#####"); mysql_select_db("joyel"); // Get information from database to work with $errorhandler = ""; $username = mysql_real_escape_string($_POST['username']); $username = strtolower($username); $password = mysql_real_escape_string($_POST['password']); $password = strtolower($password); if ($username == "") { $errorhandler .= "The Login Username was left blank.<br />"; } if ($password == "") { $errorhandler .= "The password was left blank.<br />"; } if ($errorhandler != "") { echo "<span class=\"spanred\">"; echo $errorhandler; echo "</span>"; } if ($errorhandler == "") { $password = md5($password); $selectemail = "SELECT * FROM userinfo WHERE email = '$username';"; $queryemail = mysql_query($selectemail); if ($rowemail = mysql_fetch_array($queryemail)) { // checks if email exists $selectpass = "SELECT * FROM userinfo WHERE email = '$username' AND password = '$password';"; $querypass = mysql_query($selectpass); if ($rowpass = mysql_fetch_array($querypass)) { $_SESSION['username'] = $rowpass['email']; $_SESSION['schoolaccess'] = $rowpass['schoolname']; $_SESSION['controller'] = true; $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; $_SESSION['lastlogin'] = date("m/d/y"); echo "<p>Please finish the login process by clicking the link below.</p><br />"; echo "<a href=\"/index.php?school={$_SESSION[schoolaccess]}\" title=\"Finish Login\">Finish Login Process</a>"; }else { // Send email to account owner, notifying him of date and time of attempted access // With improper password to his/or her account echo "You have attempted an unauthorized access.<br />"; echo "If you are not the user of this account, please discontinue this activity "; echo "immediately."; echo "The original account owner was sent all of your computer information.  If they."; echo "Report the unauthorized attempt to administration you will be banned from the "; echo "site for an indefinite period of time."; $to = "{$rowemail[email]}"; $subject = "www.thecampussource.com: Security Issue"; $newdate = date("m/d/y"); $newtime = time(); $message = "   There has been a possible unauthorized attempt on your account.  Someone attempted to access your account via your email address, however they provided the wrong credentials.  The following information was information we were able to recover from the attempted entry.  If you are wondering whether or not this was you, please compare this IP number with your IP number for a match, if there was no match, then please contact administration, with the IP number of the person who attempted unauthorized access, with a forwarded version of this email, and we will investigate, and possible ban that user from the site. IP Address: {$_SERVER['REMOTE_ADDR']} Possible Browser: {$_SERVER['HTTP_USER_AGENT']} Date of Attempt: {$newdate} Possible Time Of Attempt: {$newtime} "; $headers = "From: Administrator@thecampussource.com"; mail($to, $subject, $message, $headers); } // end security measure }else { echo "There is no point in continuing with the process.  your email does not exist "; echo "within our database.  Please double check your email address, register, or contact "; echo "support if you feel you recieved this message in error.<br />"; } } // close error handler check ?>         </div>     </div> <?php include './includes/banner.inc.php'; // includes the banner, randomly selected from a database ?> <?php include './includes/footer.inc.php'; // includes the page footer, bottom navigation copyright ?> </div> </body> </html>[/code] Also, you know, if anyone has any advice, on how I can make that login processor page redirect automatically back to the homepage, and have it work, It would be greatly appreciated, but if not I can live with this.
  17. Ok what's going on, I can't even use location when I try and do a logout with session destroy something is messed up here, what in my php ini might affect this, can someone help, I am having to do everything were they click on a link instead of automatically redirecting.
  18. first redo some of the code, put the query itself into a variable like $insert "INSERT INTO tablename ...;"; then do the query with a handle $query = mysql_query($insert) ex cetera, then below everything type in echo mysql_error(); then return the error message here. If no error messages comes up, check your variables by echoing each of them, find out which ones are getting filled and which ones are empty.
  19. [quote]WIN 2003 Server MSSQL DB ODBC Connection through PHP[/quote] mssql sort of sucks.  Mysql would be your best bet, but if it's a huge chunk of text, use longtext type.  If it still cut's some off, then if it's temporary store it in a session, if not then you can always store an infinite amount in a file somewhere.  even if it's temporary.  But there is a huge limitation on mysql, with data type long text.  It isn't a php, or connection limitation.  You could have 50 different full length novels saved in 1 php variable.  The database however may have an upper limit, even with longtext, but a file is not limited, you can always add more to it, it just increases the bytes, taking longer to load
  20. those functions shouldn't really hurt anything.  Classes are very good, very helpful, if yuo want to learn how to do them, there not that hard.  Having that many functions just says you have a lot of reusable code, you could probably cut that in half if you converted everything over to OOP. it would probably help server some, but other than that you should be fine.  Just call them when you need them.  Well only include them if you need them.
  21. The thing is I thought you could use redirect anywhere.  Like in the middel of a page, if they do something it redirects them somewhere, I thought this could be used pretty much anywhere, to change them to other pages, when something happens.  [code]<?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php include './includes/meta.inc.php'; // includes meta tags, stylesheet, and javascript inclusion ?> </head> <body> <div id="wrap"> <?php include './includes/header.inc.php'; // inserts header, logo, and everything up there ?>     <br style="clear: both;" /> <?php include './includes/leftnav.inc.php'; // inserts left navigation ?>     <div id="content">         <div id="processor"> <h3>Sign Up Completion</h3> <?php // signing into database, and preparing for validation and entry mysql_connect("mysql185.secureserver.net", "#####", "######"); mysql_select_db("joyel"); // Get information from database to work with $errorhandler = ""; $username = mysql_real_escape_string($_POST['username']); $username = strtolower($username); $password = mysql_real_escape_string($_POST['password']); $password = strtolower($password); if ($username == "") { $errorhandler .= "The Login Username was left blank.<br />"; } if ($password == "") { $errorhandler .= "The password was left blank.<br />"; } if ($errorhandler != "") { echo "<span class=\"spanred\">"; echo $errorhandler; echo "</span>"; } if ($errorhandler == "") { $password = md5($password); $selectemail = "SELECT * FROM userinfo WHERE email = '$username';"; $queryemail = mysql_query($selectemail); if ($rowemail = mysql_fetch_array($queryemail)) { // checks if email exists $selectpass = "SELECT * FROM userinfo WHERE email = '$username' AND password = '$password';"; $querypass = mysql_query($selectpass); if ($rowpass = mysql_fetch_array($querypass)) { $_SESSION['username'] = $rowpass['email']; $_SESSION['schoolaccess'] = $rowpass['schoolname']; $_SESSION['controller'] = true; $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; $_SESSION['lastlogin'] = date("m/d/y"); $url = "http://www.thecampussource.com/index.php?school={$_SESSION['schoolaccess']}"; header("Location: {$url}"); }else { // Send email to account owner, notifying him of date and time of attempted access // With improper password to his/or her account echo "You have attempted an unauthorized access.<br />"; echo "If you are not the user of this account, please discontinue this activity "; echo "immediately."; echo "The original account owner was sent all of your computer information.  If they."; echo "Report the unauthorized attempt to administration you will be banned from the "; echo "site for an indefinite period of time."; $to = "{$rowemail[email]}"; $subject = "www.thecampussource.com: Security Issue"; $newdate = date("m/d/y"); $newtime = time(); $message = "   There has been a possible unauthorized attempt on your account.  Someone attempted to access your account via your email address, however they provided the wrong credentials.  The following information was information we were able to recover from the attempted entry.  If you are wondering whether or not this was you, please compare this IP number with your IP number for a match, if there was no match, then please contact administration, with the IP number of the person who attempted unauthorized access, with a forwarded version of this email, and we will investigate, and possible ban that user from the site. IP Address: {$_SERVER['REMOTE_ADDR']} Possible Browser: {$_SERVER['HTTP_USER_AGENT']} Date of Attempt: {$newdate} Possible Time Of Attempt: {$newtime} "; $headers = "From: Administrator@thecampussource.com"; mail($to, $subject, $message, $headers); } // end security measure }else { echo "There is no point in continuing with the process.  your email does not exist "; echo "within our database.  Please double check your email address, register, or contact "; echo "support if you feel you recieved this message in error.<br />"; } } // close error handler check ?>         </div>     </div> <?php include './includes/banner.inc.php'; // includes the banner, randomly selected from a database ?> <?php include './includes/footer.inc.php'; // includes the page footer, bottom navigation copyright ?> </div> </body> </html>[/code]
  22. I am trying to redirect someone to another location after they login.  I need it to do what it needs to do, and redirect them back to the homepage, set on what school they are suppose to, so I have to pass school through it header("Location: index.php?school={$_SESSION[schoolaccess]}"); That is what I have, but it is saying header allready sent,  I thought the location header could be sent anywhere??
  23. Ok, so it doesn't really matter about warnings.  What are they there for, like for the future when I do css layouts, do the clients look at it in a better manner when it's perfect css, or does that not matter.  A warning, I always try to add background color with color, not redifining stuff, but is there a difference between, having warnings and not having warnings??
×
×
  • 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.