Jump to content

chris_s_22

Members
  • Posts

    77
  • Joined

  • Last visited

    Never

Everything posted by chris_s_22

  1. didnt know where else to put it
  2. I'm looking into the possibility of adding a new chat with webcam capabilities. I'd like it to be customisable and able to use with my data from mysql. I did a search on google and noticed a lot of sites charge a monthly/annually fee but I don’t think this is what I want. Obviously I like it to be cheap as possible but I don’t mind paying a one off price but I like to have total control so I’m not relying on a 3rd party site. I imagine it will have to involve a java or flash Any advice on how I can achieve this
  3. Can anyone show me or point me in direction of a tutorial that limits search results 1) i want to limit the number of rows that will show up in total eg 500 / 998 so only the 500 can be viewed. 2) i also want to display 10 results per page and have link to next 10 and previous 10 as well as option to jump straight to page ? $result = mysql_query ("SELECT * FROM table_name WHERE column_name LIKE '%$search_entered%' "); $row=mysql_num_rows($result); echo "<table>"; while($row=mysql_fetch_array($result)) { $column1 = $row["column1 "]; $column2 = $row["column2 "]; $column3 = $row["column3 "]; echo "<td>$column1 <td>"; echo "<td>$column2 <td>"; echo "<td>$column3 <td>"; } echo "</table>";
  4. im trying to create a internal mail message system. though I keep running into problems can anyone point me in direction of a good tutorial or help me with mine? so far i got my database. a page that displays list of messages in brief a page that displays list of messages sent in brief now i want to be able to delete messages This is code im using to display messages. i also added a form as i thought i need some kind of checkbox and somedata to be passed then on the maildelete.php im struggling to figure out what i should be checking for and my query <?php include_once 'Connect.php'; //This starts session, connect to database and calls any functions needed $usernameid = $_SESSION['id']; $query = ("SELECT * FROM mail WHERE messageto = '$usernameid' "); $result = mysql_query($query) or die ('failed query.'); $exist = mysql_num_rows($result); if($exist=='0') { echo"You have no mail"; } else { echo "<form action='maildelete.php' method='POST' name='delete'>"; echo "<table border='1' cellspacing='1' cellpadding='1'>"; echo "<tr><td></td><td>FROM</td><td>SUBJECT</td></tr>"; while ($row = mysql_fetch_assoc($result)) { $messagefrom = $row["messagefrom"]; $messagedate = $row["date"]; $subjecttitle = $row["subjecttitle"]; $message = $row["message"]; echo "<tr><td><input name='checkdelete' type='checkbox' value='1'></td>"; echo "<td>$messagefrom</td>"; echo "<td><div align='left'>$subjecttitle</div>"; echo "$message - only want it to display 1st 50 characters...<br>"; echo "<div align='right'>$messagedate</div></td></tr>"; } echo "<tr><td><input type='submit' value='DELETE' name='submit'></td></tr></table></form>"; } ?>
  5. any help is much apreciated this is driving me insane trying to solve this
  6. after more checking i realise if i echo out session data its fine unless it came from the search results the session username is changed So im guessing that my problem is in search.php that somewhere i change the session username so the data been passed to the view.php is wrong This is the search.php <?php include 'Connect.php';?> <html><head><link href="style.css" rel="stylesheet" type="text/css"></head> <body> <div class=navigationbarbox><?php include "navigationbar.php";?></div> <?php if(!isset($_GET[submit])) { // Show the form include 'searchindex.php'; exit; } else { if (empty($_GET['searchone']) )// Check if field empty { // Reshow the form with an error $searchempty_error = 'field empty'; include 'searchindex.php'; exit; } //CHECKS USERNAME if(!preg_match("/^[a-z\d]{1,100}$/i", $_GET[searchone])) { // Reshow the form with an error $searchentery_error = "Invalid search only letters and numbers!<br />"; include 'searchindex.php'; exit; } $result = mysql_query ("SELECT * FROM members WHERE username LIKE '%$searchone%' "); $num=mysql_num_rows($result); if($num>0) { /* start the search result box */ echo '<div class="searchresults">'; echo "<table><tr>"; while($row=mysql_fetch_array($result)) { $userid = $row["id"]; $photo = $row["photo"]; echo "<td><img src='http://myurl.co.uk/NEWTEACH/userimages/$photo' width='100' height='150'><br>"; echo '<a href="profileindex.php?userid='.$userid.'">' . $row['username'] . '</a><br>'; echo '<strong>Location:</strong>' . $row['location'] . '<br>'; echo '<strong>Date of Birth:</strong>' . $row['dob'] . '</td>'; } echo "</tr></table>"; echo '</div>'; //end searchresults div } else { echo '<p>Sorry, your search returned no results!</p>'; } // end if $num } // end isset if ?> <div class=searchresult><?php echo '<strong>You searched for:</strong> ' . $searchone . '<br>'; echo 'There are ' . $num . ' results.'; ?></div> </body> </html>
  7. What else can i do to narrow down and solve the problem. Where is my problem? 1}When i go to my search index page which displays a search form. 2)The data from form is sent to the search.php for checking and displays results without a problem. 3)If i then navigate to another page other than the result links everything is fine HOWEVER.. if i click on one of the result links, it let me navigate to the page and displays fine but doesnt let me navigate away from that page. The session just seems to end so when i try visit any other page it fails on the is_authed function the is_authed function checks session data. THIS IS THE PAGE THAT RESULTS LINKS ARE DIRECTED TO <?php include_once 'Connect.php'; if (!is_authed()) { die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.'); } ?> <html><head> <link href="style.css" rel="stylesheet" type="text/css"></head> <body> <div class=logo><?php include "logo.php";?></div> <div class=navigationbarbox><?php include "navigationbar.php";?></div> <div class=photo><?php include "profilephoto.php";?></div> <div class=sidelinks><?php include "profilesidelinks.php";?></div> <div class=info><?php include "profileinfo.php";?></div> <div class=footerbox><?php include "footer.php";?></div> </body></html> MY SESSION IS THE FIRST THING IN CONNECT.PHP which also conect to database and calls for any functions needed. the logo just contains <img src="images/logo.jpg" alt="" width="300" height="65"> no php whatso ever the navigation contains my navigation bar this includes connect.php profilesidelinks as the names says is side bar link also inlcudes connect.php profileinfo includes connect.php and just queries database and displays info footer as the name suggest is the footer with links no php whatso ever
  8. silly me in the inner loop i was using same variables as the outter loop ive since changed them im now getting the echo message "You have no friends" even though i know in database there is my connect.php consists of session start, conects to database then calls for the functions page. i use a include to connect.php on each page so a session should be there but ive realised that if i echo out the session id its blank but if i echo out session username it shows the username any advice guys?
  9. i dont think the problem is the is_authed function as ive used this on all my pages i wish to protect without any problem. it basically checks session data if i take out this part and replace with a simple echo statment it works fine which tells me it is this part of the code while ($row = mysql_fetch_assoc($result)) { $friendwithid = $row["friendwith"]; $query = ("SELECT * FROM members WHERE $friendwith = '$friendwithid'"); $result= mysql_query ($query) or die ('Could not query.'); while ($row = mysql_fetch_assoc($result)) { $photo = $row["photo"]; $username = $row["username"]; } echo "<img src='http://www.myurl.co.uk/NEWTEACH/userimages/$photo' width='100' height='150'><br>"; echo"$username<br>"; echo'<a href="friendsdelete.php?userid='.$userid.'">Remove Friend</a>'; }
  10. my connect.php starts the session just so you know i can navigate arround my site fine except when i come to this page. it lets me in but then when i try to leave no matter what page i go to or which page i come from it shows the error !is_authed Also can someone check my code i wasnt sure if i could do a loop within another one <?php include_once 'Connect.php'; if (!is_authed()) { die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.'); } ?> <html><head><title>Untitled Document</title> <link href="style.css" rel="stylesheet" type="text/css"></head> <body> <div class=logo><?php include "logo.php";?></div> <div class=navigationbarbox><?php include "navigationbar.php";?></div> <div class=welcome> <?php // Checks friends $member = $_SESSION["id"]; $query = ("SELECT * FROM friends WHERE member = '$member'"); $result= mysql_query ($query) or die ('Could not query.'); $exist = mysql_num_rows($result); if($exist=='0') { echo"You have no friends"; } else // if any friends gets { while ($row = mysql_fetch_assoc($result)) { $friendwithid = $row["friendwith"]; $query = ("SELECT * FROM members WHERE $friendwith = '$friendwithid'"); $result= mysql_query ($query) or die ('Could not query.'); while ($row = mysql_fetch_assoc($result)) { $photo = $row["photo"]; $username = $row["username"]; } echo "<img src='http://www.myurl.co.uk/NEWTEACH/userimages/$photo' width='100' height='150'><br>"; echo"$username<br>"; echo'<a href="friendsdelete.php?userid='.$userid.'">Remove Friend</a>'; } } ?> </div> <div class=footerbox><?php include "footer.php";?></div> </body> </html>
  11. would this be consider right? while($row=mysql_fetch_array($result)) { $userid = $row["id"]; echo '<a href="profileindex.php?user_id='$userid'">' . $row['username'] . '</a><br>'; }
  12. the $username is the session data the site im creating so far users can register/login which starts a session user then can upload photos, edit there profiles and view there own profile when they goto view.php user can search for other user this is where im up to. i want a user to be able to, not only search but to click on there name and view there profile when someone uses my search it dispalys some brief users data with a link. if a user clicks on that link i want it to display there data NOT THE SESSION DATA but... i need the script to carry on as it is displaying session data so if a user visit view.php it still views there data I ONLY need to do the above if it came from the search results. im guessing i have to add something to the search results link view.php? this should send data to the view.php then on the view.php do a check to see if it there was any data sent otherwise to do what it was original just im not sure exactly what
  13. when i do a search on the database i display data like so echo '<a href="view.php">' . $row['username'] . '</a>'; if a user clicks on the link of a result it takes them to a page that does includes for each part of a page. This is view.php <?php include_once 'Connect.php'; if (!is_authed()) { die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.'); } ?> <html><head><title>Untitled Document</title> <link href="style.css" rel="stylesheet" type="text/css"></head> <body> <div class=logo><?php include "logo.php";?></div> <div class=navigationbarbox><?php include "navigationbar.php";?></div> <div class=photo><?php include "image.php";?></div> <div class=sidelinks><?php include "sidebar.php";?></div> <div class=info><?php include "info.php";?></div> <div class=footerbox><?php include "footer.php";?></div> </body></html> the logo,navbar and footer will always be same, however the image, sidebar and info will differ currently each page is coded to display the session users data. this is image.php <?php include_once 'Connect.php'; $thequery = ("SELECT * FROM members WHERE username = '$username' "); $query = mysql_query($thequery) or die ('failed query.'); while ($row = mysql_fetch_assoc($query)) { $photo = $row["photo"]; } ?> <html> <head></head> <body> <img src="http://www.escortellie.co.uk/NEWTEACH/userimages/<?php echo $photo?>" width="100" height="150"> </body> </html> i want it still to display the sesion data but if came from the search to display the data of that user instead which parts and how do i alter my code so this can be acomplished
  14. This is the code i use to upload a photo to a folder and put file name in database. However if someone was to re use the form to change photo id like it so that the old one was deleted How do i do this <?php include 'Connect.php'; if(!isset($_POST[submit])) // checks that the data being recieved came from a POST variable named 'submit' { // if error reshow the form You cannot access this page directly. include 'index.php'; exit; } else { if ((($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/pjpeg")) && ($_FILES["photo"]["size"] < 51000)) { $ext = findexts ($_FILES['photo']['name']) ; //This applies the function to our file $ran = rand () ;//This line assigns a random number to a variable. $ran2 = $ran."."; //adds a . on the end of $ran $target = "images/"; //This is the directory where images will be saved $pic = $ran2.$ext;//This gets information from the form that has since been randomised and checked $target = $target . $ran2.$ext;//This combines the directory, the random file name, and the extension //If everything is ok we try to upload it //Writes the information to the database mysql_query("UPDATE members SET photo = '$pic' WHERE username = '$username'") ; if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { header('Location: index.php'); } else { echo "Sorry, there was a problem uploading your file."; } } else { echo "Invalid file"; } } ?>
  15. would this be ok? $types = array("type/jpg", "type/jpeg", "type/pjpeg", "type/PJPEG", "type/JPG", "typ/JPEG", "type/gif", "type/GIF", "type/png", "type/PNG");if(!in_array($uploaded_type,$types)){ echo "Invlaid file type"; $ok = 0;}
  16. both of these are suposed to check url is in correct format? this should only alow http:// with domain name with no folder extentions if(!preg_match("/^http://[0-9a-zA-Z-.].[a-zA-Z]{2,3}$/", $_POST[linkto])) this should alow as above but with folder ext if(!preg_match("/^http://(www.[0-9a-zA-Z][0-9a-zA-Z-][0-9a-zA-Z]|[0-9a-zA-Z][0-9a-zA-Z-][0-9a-zA-Z]).[a-zA-Z]{2,3}[0-9a-zA-Z/-_.]$/", $_POST[linkfrom]))
  17. ive got a upload photo script and im just trying to make more secure currently it limits size and as you can see from my code below it limits only gif and php files how do i edit my code to limit all these or do i have to copy and paste the same code and change the file extention? jpg, jpeg, pjpeg, PJPEG, JPG, JPEG, gif, GIF, png, PNG if (!($uploaded_type=="image/gif")) { echo "You may only upload GIF files.<br>"; $ok=0; } also ive restricted php is there anything else i need to restrict? if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; }
  18. im very aware thast it would refuse http://google.com but as i said in my post i will be making the user aware to make sure they type both http:// and the www.
  19. im trying to validate url's sent to me by a form the url's im collecting are for placing banners on my site so the url's are the link to there site and url of where there banner is URL's ARE BROKEN INTO PARTs PROTOCOL/SUBDOMAIN/DOMAIN NAME/DIRECTORY/FILE SO FAR I GOT if(!preg_match("/^http://www.[a-z0-9-].[a-z]{2,3}[a-z0-9/.] $/i", $_POST[url])) This checks the form feild url 1) make sure http://www. is present (i dont see why it should be any different for the purpose of my use) i wll be placing a warning on my form page that the urls must contains this 2) Then my code checks it consists of only letters,numbers,dashes/hythens i read these are the only characters a domain name can be also they must start with a letter or number so how do i make that possible? 3) the next part makes sure theres a . 4) the next part makes sure it consists of only letter of 2-3 characters long this only alows things such as .com or .ru How do i alow multiple for example .co.uk 5) i then want to make the rest optional but to alow letter/numbers/for directories . for start of ext can anyone help me tweak my code to satisfy my needs but to be as strict as possible. also knowing what my code is going to be checking is there any genuine urls that the code would refuse or is there anything i need to know
  20. lol nope you was right doing it in two lines causes the query to re do $result so had to take it out and use the one line method unless i renamed $result2 if that makes any sense to you
  21. i was under the impression that the method you shown with one line is the same as the way i do it in 2 and both ways still run the query or am i wrong $result = mysql_query("UPDATE links SET checked='0' WHERE linkfrom='$linkfrom'"); $query = ("UPDATE links SET checked='0' WHERE linkfrom='$linkfrom'"); $result= mysql_query ($query) or die ('Could not query.');
  22. ok thx for advice first i changed the select query not sure if that makes a difference i then as you advised changed $linkcheckcontents = file_get_contents ($result); this i totally understand regards to the 2 queries i added a line underneath each im a bit unsure what i would put in the where statement so i added $linkto = $row["linkto"]; then $query = ("UPDATE links SET checked='1' WHERE linkfrom='$linkfrom'"); is this fine can you see anything else? this is full code im using <?php // FIRST I WANT TO GET LINKFROM COLUMN DATA FROM DATABASE - THIS CONTAINS URL's TO PAGES WHERE I WOULD EXPECT A RETURN LINK BACK TO MY SITE $query = ("SELECT * FROM links"); $result= mysql_query ($query) or die ('Could not query.'); // I THEN WANT TO CHECK EACH ROW while ($row = mysql_fetch_assoc($result)) { $linkto = $row["linkto"]; // SO I DEFINE MY URL $mylink = "http://www.yoururlhere.com"; // FROM THE URL STORED IN DATABASE COLULMN GET THE URL PAGE RETURN AS A STRING $linkcheckcontents = file_get_contents $row['linkfrom']); if ($linkcheckcontents == FALSE) echo 'Could not open'; else { //CHECKS THE LINK RETURNED AS A STRING CONTAINS MY $MYLINK if( (stristr($linkcheckcontents, '<a href="'.$mylink) === FALSE) && (stristr($linkcheckcontents, "<a href='" .$mylink) === FALSE)) { // IF $MYLINK DOESNT APPEAR SET checked='0' $query = ("UPDATE links SET checked='0' WHERE linkfrom='$linkfrom'"); $result= mysql_query ($query) or die ('Could not query.'); } else { // IF $MYLINK APPEARS SET checked='1' $query = ("UPDATE links SET checked='1' WHERE linkfrom='$linkfrom'"); $result= mysql_query ($query) or die ('Could not query.'); } } // GOES BACK TO START AND REPEATS FOR NEXT ROW } ?>
  23. im trying to allow users to add links to my links page themselves. but only display links where i have a rteturn link back to me ive created the table in database, the form, a page to check form data and then inserts data into database, ive got a page that displays the checked links but now im trying to do the return link checking, i carnt test it till later on so in the mean time id be grateful if someone could go through and check my code im only a php beginner so expect silly mistakes ive tried to be as descriptive as i can to what im doing. <?php // FIRST I WANT TO GET LINKFROM COLUMN DATA FROM DATABASE - THIS CONTAINS URL's TO PAGES WHERE I WOULD EXPECT A RETURN LINK BACK TO MY SITE $query = ("SELECT linkfrom FROM links"); $result= mysql_query ($query) or die ('Could not query.'); // I THEN WANT TO CHECK EACH ROW while ($row = mysql_fetch_assoc($result)) { // SO I DEFINE MY URL $mylink = "http://www.yoururlhere.com"; // FROM THE URL STORED IN DATABASE COLULMN GET THE URL PAGE RETURN AS A STRING $linkcheckcontents = file_get_contents ($result); if ($linkcheckcontents == FALSE) echo 'Could not open'; else { //CHECKS THE LINK RETURNED AS A STRING CONTAINS MY $MYLINK if( (stristr($linkcheckcontents, '<a href="'.$mylink) === FALSE) && (stristr($linkcheckcontents, "<a href='" .$mylink) === FALSE)) { // IF $MYLINK DOESNT APPEAR SET checked='0' $query = ("UPDATE links SET checked='0'"); } else { // IF $MYLINK APPEARS SET checked='1' $query = ("UPDATE links SET checked='1'"); } } // GOES BACK TO START AND REPEATS FOR NEXT ROW } ?> if you do find any mistakes id be very gratful if you could explain why its wrong thanks in advance
  24. any ideas how i update my session? when someone logs into site it creates a session // Now encrypt the data to be stored in the session $encrypted_id = md5($user['id']); $encrypted_name = md5($user['username']); // Store the data in the session $_SESSION['id'] = $id; $_SESSION['username'] = $username; $_SESSION['encrypted_id'] = $encrypted_id; $_SESSION['encrypted_name'] = $encrypted_name; this code is what im using $query = "UPDATE members SET username = '$newusername' WHERE username = '$username'"; $result= mysql_query ($query) or die ('Could not create user.'); // if suceesfully inserted data into database, if($result) { $_SESSION['username'] = $newusername; header('Location: home.php'); } as you can see this updates the username then redirects to home.php this page checks if the user is_authed so i need to update session data
  25. yes it is in the connect.php like i say at the start of my post it is from this line it isnt doing what i want it to do if ($newusername == $_SESSION['username']); if i echo out $newusername it always is what i type in the form box i have since replaced this $_SESSION['username'] with $username and if i echo out $username i get the stored session username but no matter what i type it echos out the $username_errortwo error
×
×
  • 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.