Jump to content

markspec87

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by markspec87

  1. I know this is really simple (i think) but i cant remember the code. How do i show records based on the value of another? i.e select the record where username = "spec" so i can then assign specs age and location etc to different variables.
  2. Ive run into another problem aswell. When i upload to /uploads/ its absolutely fine. However if i do /uploads/files/ It throws the error: [quote]Warning: move_uploaded_file(./uploads/files/PF.txt): failed to open stream: Permission denied in /home/terraarm/public_html/includes/uploader.php on line 13[/quote] any ideas?
  3. I have a script to upload files, its pretty simple. form [quote]<form enctype="multipart/form-data" action="uploader.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> [/quote] uploader.php [quote]$target = "../uploads/"; $target = $target . basename( $_FILES['uploaded']['name']); if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } ?> [/quote] My question is how could i modify the uploader to add something onto the filename? i.e add the variable $id onto the front of every uploaded file?
  4. hmm run into a problem. I can now login and logout fine. When i login i can see the personalised message but then when i got to another page with the same code for a welcome message, it goes off. Ive put session start at the top. What am i missing?
  5. to solve these problems i always put session stuff at the very top of the document. works a treat :)
  6. thanks for that. Managed to get the files found to be links to them aswell. Works a treat :)
  7. oo sigh. My host has php4 says that command is php5 :( Is there an alternative?
  8. Is there anyway i can error catch with that? i.e If no files are found echo "no files were found" ?
  9. Is there anyway PHP can output the filenames of files in a specific folder on my site? :)
  10. Ive fixed it :) Although i wouldnt mind knowing how to end the session for a logout page.
  11. Some success The code works but it also thorws errors above the working text: [quote]Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/terraarm/public_html/index.php:6) in /home/terraarm/public_html/index.php on line 30[/quote] Any fix for this except covering the entirity of my page in php tags and echoing? EDIT: Never mind fixed that :)
  12. i used   [quote]<?php if (isset($_SESSION['username'])) {     echo 'Welcome, ' . $_SESSION['username']; } else {     echo "Welcome to my website!"; } ?>[/quote] but it always says "Welcome to my website!" any ideas?
  13. thanks for that, login works perfectly. So what code could i use to detect if a session is in progress? I.e if there is a session, say "welcome username!" thanks
  14. So would this be right? [quote]session_start(  );     session_register("username");     session_register("accesslevel");     $username=$_POST['nickname'];     $accesslevel = "select accesslevel from members where username = '".$_POST['username']."' and password = '".$_POST['password']."';"; [/quote] Thats part of the code if they have specified the right username and password. Guidance would be appreciated :)
  15. i thought it best to make a thread about this. Ive got a signup / login script sorted now (adds and checks info in databse) But im unsure how to use cookies or sessions to implement into it my site. What code or commands do i need to use to check if someones logged in and/or log them in / out? thanks
  16. I have a page where users can submit thier own news / articles. When they complete this form is there any code  ican use to email me that someone has added something (at the same time as it adds it to the database)
  17. Ok ive signed up on the site / Logged in ,yet the text still says "your not logged in" Am i missing something?
  18. How would i do it based on what the above login script is using? EDIT: also could the welcome message say that, but if they arent logged in say "your not logged in, signup here" etc thanks for all your help.
  19. Thanks for that revised code, works a treat. Now my second Question :) Now the use ris logged in using that, how could i A) say "welcome *username here" B) Allow viewing of some webpages based on thier accesslevel. I.e if the database column level = 2 for the logge din user, they can view the pages contents. Sorry about the beginner questions but im just getting ym head around more advanced php. Ive never used cookies before.
  20. Got a couple of questions i need help with. Firstly i have a signup and login script. Signup works but when people login it says [quote]Warning: Cannot modify header information - headers already sent by (output started at /home/terraarm/public_html/includes/login.php:3) in /home/terraarm/public_html/includes/login.php on line 29[/quote] Ive eliminated al lthe white space and stuff from the file but it still throws this error FIle contents: [quote]<?php echo "<html>"; echo "<head>"; echo "<title>Login</title>"; echo "</head>"; echo "<body>"; $server = "REMOVED"; // db host $db_user = "REMOVED"; // db username $db_pass = "REMOVED"; // db password $database = "REMOVED"; // db name // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $match = "select id from member where username = '".$_POST['username']."' and password = '".$_POST['password']."';"; $qry = mysql_query($match) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows <= 0) { echo "Sorry, there is no username $username with the specified password.<br>"; echo "<a href=login.php>Try again</a>"; exit; } else { setcookie("loggedin", "TRUE", time()+(3600 * 24)); setcookie("mysite_username", "$username"); echo "You are now logged in!<br>"; echo "Continue to the <a href=index.php>members</a> section."; } echo "</body>"; echo "</html>"; ?>[/quote] Any ideas? question 2: using that script above how could i check a user is logged in and what rights? (i.e if they have access level 2, they can see the admin panel) thanks
  21. ive got a page where i use this code to display data from my database. [code]$query="SELECT * FROM results WHERE autonumber = $_GET[id]";[/code] When they goto the index page and click a result it would goto "results.php?id=1/2/3/" And display the appropiate data. My question is, how can i get the page to display "No data specified" or something similar when someone just types results.php with no ID. At the moment it will just show the page with the database driven areas blank. thanks :)
  22. This is a follow on from my previous post but i thought its essentially a different question. I got my variable $domain. How do i check that to see if it contains .co.uk or .net for example? I.e "IF $domain contains .co.uk then price = 5.99 else price = 7.99" :)
  23. that file doesnt exist i put that there becuase thats what im looking to do. You say "And then have buy.php extract the get key domain" how do i do that? thats what i want to know :)
  24. it isnt using a form. example: www.terra-army.com/whois/whois.php Im trying to get it so when they click available, it takes them to the ordering page and passes on the domain they want registered (stored in $domain) source code for script - www.terra-army.com/whois/whois.txt
×
×
  • 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.