
coolphpdude
Members-
Posts
214 -
Joined
-
Last visited
Never
Everything posted by coolphpdude
-
[SOLVED] Upload Pictures and include checks in the validation
coolphpdude replied to mikebyrne's topic in PHP Coding Help
have you changed the write permissions to the folder that you are uploading the picture?? -
to put it in the most simplest of terms, how do i execute a command that will delete a file from my host?
-
sorry i think you have misunderstand, i meant the user (fred in this case) has uploaded a document. I am using a MySQL database with various tables. One table within this database is a user table consisting of basically these 2 fields 'username' and 'uploaded_file'. Fred logs in to my site, uploads 'histext.doc', the file is sent to my hosting and the path is added to freds 'uploaded_file' field. If fred uploads a second document i want the original document to be deleted from my web hosting and replaced with the second file. I know how to move the file to the hosting, i also now how to upload the field on the database, i just need to know how to remove the existing file. I am saying the user will only be able to have one uploaded file for the purpose of the example to make things less complicated, the user will in fact be able to upload as many files as necessary, therefore renaming the file to the users username would not be feasable. any help is much appreciated
-
Hi there, Ive got my upload code working spot on. you choose the file you want to upload and it sends it to my hosting, if the file exists it randomly renames the file and then uploads it. The target path is stored in a field on my database so for example user fred uploads histext.doc the uploaded field on my database would be '/userfiles/fred/histext.doc'! However, I only want the user to be able to upload 1 single file, if they upload another file it should replace the existing file. so basically i need to know how to delete the existing file. so fred uploads newtext.doc, histext.doc is deleted from my hosting, newtext.doc is uploaded and the new target path is updated in my database. any ideas??
-
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
that works!! its really wierd because i tried $_GET before $_POST without it working! ??? never mind, it works now, thats great! thanks ALOT for your help!!! -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
Post Overview Page... <?php session_start(); // Take the sessions into variables $user_session_id = $_SESSION['user_session_id']; $user_session_password = $_SESSION['user_session_password']; // Run user query (checks if the login credentials are correct) $user_query = "SELECT * FROM user WHERE user_id='$user_session_id' and user_password='$user_session_password'"; if ($user_result = mysql_query($user_query)) { if ($user_rows = mysql_num_rows($user_result)) { $my_user_row = mysql_fetch_array($user_result); } } // posts Quesry $post_result = mysql_query("SELECT * FROM posts WHERE user_id='$user_session_id'", $db); // Check that something was found $post_rows=@mysql_num_rows($post_result); if(!$user_rows) { do_error("No results found"); } else { echo "<table border='2' cellspacing='1' cellpadding='1' align=center bordercolor='#648CC8' style='border-collapse: collapse'>\n"; echo "<caption><h2><font color=blue></font></h2></caption>\n"; echo "<tr><th>post ID</th><th>Subject</th><th>Sender</th><th>Date & Time</th></tr>\n"; while ($my_post_row = mysql_fetch_array($post_result)) { printf("<tr><td><a href=\"mypostselect.php?id=%s\">%s</a></td>\n", $my_post_row["post_id"], $my_post_row["post_id"]); printf("<td>%s</td>\n", $my_post_row["post_subject"]); printf("<td>%s</td>\n", $my_post_row["post_sender"]); printf("<td>%s %s</td>\n", $my_post_row["post_date"],$my_post_row["post_time"]); } } echo "</table>\n"; } // *********************** No Results ************************** function do_error($error) { echo "USer not found"; } echo "</html>"; ?> Selected Post Page... <?php session_start(); // Take the sessions into variables $user_session_id = $_SESSION['user_session_id']; $user_session_password = $_SESSION['user_session_password']; $id = $_POST['id']; // post SELECTED Query $selected_post_result = mysql_query("SELECT * FROM posts WHERE post_id='$id'", $db); // Check that something was found $selected_post_rows=@mysql_num_rows($selected_post_result); // takes each cell of an array into a variable $selected_post_row = mysql_fetch_array($selected_post_result); echo "$user_session_id"; echo "$id"; ?> I think thats all the userless crap removed from them two pages -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
ahh right give me a couple of minutes and i'll copy everything in -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
would it just be easier to turn register_globals on?? I only really want to allow a user to select an id on 1 page and view more information about that id on the following page. only way i can think of doing it is by passing that ID over the URL. Worked before but not now. -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
this is still not working. I have pasted my selected code page (without my database connections on it). is this what you mean?? <?php session_start(); // Take the sessions into variables $user_session_id = $_SESSION['user_session_id']; $user_session_password = $_SESSION['user_session_password']; $id = $_POST['id']; // post SELECTED Query $selected_post_result = mysql_query("SELECT * FROM posts WHERE post_id='$id'", $db); // Check that something was found $selected_post_rows=@mysql_num_rows($selected_post_result); // takes each cell of an array into a variable $selected_post_row = mysql_fetch_array($selected_post_result); echo "$user_session_id"; echo "$id"; ?> -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
in the previous page (the posts.php page). printf("<tr><td><a href='postselect.php?id=%s'>%s</a></td>\n", $post_row["post_id"], $post_row["post_id"]); ...the above bit of code is in a page that displays an overview of posts, the user clicks the post_id which is held in the URL. This worked previously on my uni page which ive been told must have register_globals off. Yeah i know it should be better written, i'll work on that. -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
top of both pages... // post SELECTED Quesry $selected_post_result = mysql_query("SELECT * FROM posts WHERE post_id='$id'", $db); // Check that something was found $post_rows=@mysql_num_rows($selected_post_result); // takes each cell of an array into a variable $post_row = mysql_fetch_array($selected_post_result); -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
hey right, doubles quotes changed and the GET bit added to the selected post page. ITs kind of like a forumn page, the first page is an overview of all the posts with a post_id, the user clicks the post_id which is a URL link to postselect.php and i do a search query on that page for all posts where post_id is equal to $id. posts.php... printf("<tr><td><strong><font face='arial'><font color='#648CC8'><a href='postselect.php?[color=red]id=%s[/color]'>%s</a></font></strong></td>\n", $post_row["post_id"], $post_row["post_id"]); postselect.php... search query... $selected_post = mysql_query("SELECT * FROM posts WHERE post_id='$id'", $db); $id = $_GET['id'] for example if the post_id was 1 the url of the postselect page would be postselect.php?id=1 it's still not working so i hope this explanation is this a bit clearer? -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
theres bot really any need to encode the URL anyway as the user will see this $id and this is what we want to pass via the URL -
[SOLVED] passing a variable in the URL
coolphpdude replied to coolphpdude's topic in PHP Coding Help
wot do you mean? -
Im having a problem passing a variable between pages through the URL. Ok, new problem, im guessing its caused by the same issue though!! If i was allow the user to select a link and send an id accross it by doing the following... printf("<tr><td><a href=\"postselection.php?id=%s\">%s</a></td>", $post_row["post_id"], $post_row["post_id"]); ...it would work on my previous webpage but not on my new hosting. to test to see if the variable is being passed accross i used... echo "$id"; .... and nothing was output so im guessing its not holding the variable when moving to the next page. any idea's??
-
or at least know a way round it??
-
Ok, new problem, im guessing its caused by the same issue though!! If i was allow the user to select a link and send an id accross it by doing the following... printf("<tr><td><a href=\"postselection.php?id=%s\">%s</a></td>", $post_row["post_id"], $post_row["post_id"]); ...it would work on my previous webpage but not on my new hosting. to test to see if the variable is being passed accross i used... echo "$id"; .... and nothing was output so im guessing its not holding the variable when moving to the next page. any idea's??
-
Thanks thats great
-
$message_result = mysql_query("SELECT * FROM usermessages WHERE user_id='$user_session_id' ORDER BY date AND time", $db); ???
-
Hey again, If im doing a message board type system and i want to arrange messages by date and time how do i do it? at the moment im just selecting all records from my message table where user id=xx then outputting the messages using a while loop
-
Well it works now so thats great, thanks mate, much appreciated again!!
-
right, ive added this to the start of my page $user_session_id = $_SESSION['user_session_id']; $user_session_password = $_SESSION['user_session_password']; ...and it now works. any idea why i didnt need to do this on my original site???
-
ive got... <?php session_start(); at the beginning of every page. i set the session on the login code before automatically sending the logged in user to the useraccount.php page so it shud be carried over in the session shudnt it? this is the way i have done it when i originally created the site and it worked fine
-
Hi there. I'm transferring my work from my uni hosting page to my home webpage. Ive recreated the databases exactly so they are identicle (and double checked this) i've changed the connection information at the beginning of each of my php pages. my problem lies with sessions! For some reason the code which works on my uni website and holds the following sessions throughout my site works, but not at home! // take the user id into the session id called user_session_id $_SESSION['user_session_id'] = $user_id; // take the login password into the session id called user_session_password $_SESSION[user_session_password'] = $user_password; // go to page header ("location: useraccount.php"); exit; now when i authenticate this user on the useraccount.php page theres no user found and ive narrowed it down to the sessions. my authentication is... // Run user query (checks if the login credentials are correct) $user_result = mysql_query("SELECT * FROM user WHERE user_id='$user_session_id' and user_password='$user_session_password'",$db); Any idea why this might be??
-
ahh so carry forward the original search keyword and then take in the refined search as '$refine' then resubmit the search as select * from holidays where holiday_hotel = $keyword AND holiday_location = $refine??