
ROCKINDANO
Members-
Posts
143 -
Joined
-
Last visited
Never
Everything posted by ROCKINDANO
-
Hello all, well i am working on a project here. and its a app. where a user uploads a file to a dir. and a page should list the file info. for example, the date, a link to view the file. i have it to where i can upload the file to a dir, insert to the db (file info) and display the record from the db. BUT, i am having trouble with getting the date and making the link display on the page. this is what i have: uploadform.php <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>upload pdfs</title> </head> <body> <form action="uploadpdf.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="51200" /> <p>File to upload: <input type="file" name="fileupload" /></p> <p><input type="submit" value="upload!" /></p> </form> </body> </html> uploadpdf.php <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>uploading file</title> </head> <body> <?php $file_dir = "G:\cityweb1\pdfs\citysect"; $file= $_FILES['fileupload']; print "path: ".$file['tmp_name']. "<br />"; print "name: ".$file['name']."<br />"; print "type: ".$file['type']."<br />"; print "size: ".$file['size']."<br />"; print "error: ".$file['error']."<br />"; if (is_uploaded_file($file['tmp_name'])) { move_uploaded_file($file['tmp_name'],"$file_dir/".$file['name']) or die ("could not moved"); print "file was moved!<br />"; if(!($db = @ mysql_connect('localhost', 'user', 'pass'))) { print "Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time."; } //select which database you want to edit mysql_select_db("edinburg_site"); $agenda_id=$_POST["agenda_id"]; $adate=$_POST["adate"]; $link=$_POST["link"]; $query= "INSERT INTO ccagenda VALUES (null,'{$adate}','{$link}')"; $result=mysql_query($query); while ($r=mysql_fetch_array($result)) { $agenda_id=$r['agenda_id']; $adate=$r['adate']; $link=$r['link']; } } ?> </body> </html> display all records from that db here <?php if(!($db = @ mysql_connect('localhost', 'user', 'pass'))) { print "Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time."; } //select which database you want to edit mysql_select_db("edinburg_site"); $agenda_id=$_GET[agenda_id]; print "<center><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\">"; $query="SELECT * FROM ccagenda ORDER BY agenda_id DESC"; $result=mysql_query($query); while ($r=mysql_fetch_array($result)) { $agenda_id=$r['agenda_id']; $adate=$r['adate']; $link=$r['link']; print "<tr><td colspan=\"2\">"; print "<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"2\" bgcolor=\"#E8DFBB\">"; print "<tr>"; print "<td width=\"50%\" align=\"left\" style=\"color:#3949f9\">" .$adate. "</td>"; print "<td align=\"right\" width=\"50%\">" .$link. " <img src=\"images/pdfimage.png\" title=\"\" border=\"0\" /></td>"; print "</tr>"; print "</table>"; print "</td></tr>"; } print "</table></center>"; ?> this page displays 0000-00-00 for date and no link. this is where i have trouble. how do i get the date and link into the db? PLEASE HELP!!!!!!
-
ah.... got it. Thanks for all your help
-
this is the output i am getting now path: name: PZpgchanges (2).pdf type: size: 0 error: 2 not uploading to dir path
-
well this is what i have: uploadform.php <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>upload pdfs</title> </head> <body> <form action="uploadpdf.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="51200" /> <p>File to upload: <input type="file" name="fileupload" /></p> <p><input type="submit" value="upload!" /></p> </form> </body> </html> uploadpdf.php <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>uploading file</title> </head> <body> <?php $file_dir = "pdfs\\citysect\\"; foreach ($_FILES as $file_name => $file_array) { print "path: ".$file_array['"tmp_name"']. "<br />"; print "name: ".$file_array[''"name"]."<br />"; print "type: ".$file_array["'type'"]."<br />"; print "size: ".$file_array[''"size"]."<br />"; if (is_uploaded_file($file_array['"tmp_name"'])) { move_uploaded_file($file_array['"tmp_name"'], "$file_dir\".$file_array["name"]") or die ("could not moved"); print "file was moved!<br />"; } } ?> </body> </html> but its not uploading!!! can't see the error help!
-
thats right, i was thinking of uploading the acctual file into the db, but instead i could send it to a dir. and upload the db at the same time. hhhmmmm.. but how would i go about uploading the db at the same time?
-
right, acctually thats how i have it right now. but these are pdf's that are being listed weekly. so every time they put one in a folder i have to input a new record in a db. so i was thinking of having the files uploaded to db that way everytime that they do upload it produces a new link on the page with the current pdf. anyways, i guess ill keep it as i have it. but what would be one disadvantage of storing them in a db?
-
Hello all, i have a question, will it be convenient to store pdf files on a db? if so can someone point me to a direction on how to?
-
i do call session start on all my scripts. i just have it in the head part
-
Hello all, i am working on a project on posting job openings. i have 2 tables (fulltime and parttime). they list all opening available. so i have a log in page (login.php) where user types user name and password. then goes to validate and then takes them to the form that must be filled to update db. however, when i log in it show my user name and takes me to the form. but once i update a table, i have a confirmation page that list links to view posting or back to the update form. but when i click on the post another which will take me back to the update form it throws me back to the login page instead. ??? i am guessing its with the sessions on keeping the ip_addr or user_id. any help? here are my five files: login.php <form method="post" action="validatehr.php"> <div class="intro"> <p style="color:#999999">Welcome, you have reached the City of Edinburg's Human Resource login form. Please log in using your login credentials, in order to update job postings. After logging in you will be prompt to choose whether you want to up date the full-time or part-time openings.</p> </div> <div class="loginform"><br /> <p style="color:#999999">User Name: <input type="text" name="user_name" size="15" maxlength="25" style="border:1px solid #999999" /> </p> <p style="color:#999999">Password: <input type="password" name="password" size="15" maxlength="25" /><br /> </p> <br /> <input type="submit" name="submit" value="Login" /> <input type="submit" name="Cancle" value="Close Window" onclick="window.close()" /> </div> </form> validatehr.php <?php if(!isset($_POST["user_name"]) || !isset($_POST["password"])) die("invalid operation5555555555"); $goback = "<br /><br />Please <a href=\"login.html\">go back</a> and try again."; if(empty($_POST["user_name"])) die("<br />The username field cannot be left blank11111."); if(empty($_POST["password"])) die("<br />The Password field cannot be left blank"); $user_name = $_POST["user_name"]; $password = md5(trim($_POST["password"])); // $user_name = mysql_real_escape_string($_POST["user_name"]); if (!$db = mysql_connect('localhost','XXXXX','pass')) { print"Error: could not connect to the database.<br>".mysql_error(); exit; } @mysql_select_db('edinburg_site') or die(mysql_error()); $query = "SELECT * FROM `users` WHERE user_name = '{$user_name}' AND password = '{$password}'"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) == 0) die("<br />Invalid username or password!<br />{$goback}"); $row = mysql_fetch_array($result); session_start(); $_SESSION["user_id"]=$row["user_id"]; $_SESSION["ip_addr"]=$_SERVER["REMOTE_ADDR"]; $_SESSION["user_name"]=$row["user_name"]; header("LOCATION: hrupdatefull.php"); ?> hrupdatefull.php <?php $user_id=$_SESSION["user_id"]; $ip_addr=$_SESSION["ip_addr"]; if($ip_addr != $_SERVER["REMOTE_ADDR"]) die("invalid operation!!!<br /> please login first"); //DISPLAYS USERNAME IF ALREADY LOGGED IN. if(isset($_SESSION["user_name"])) { print"<div style=\"float:right; border:1px solid $000000\"><p style=\"font-size: 10px\">You are logged in as: <br />"; print "".$_SESSION["user_name"]." "; if(isset($_SESSION["user_name"])) print"<a href=\"logout.php\">Logout!</a></p></div><br />"; print"Hello, {$_SESSION['user_name']} "; print"Welcome."; print $user_id; print $user_name; } else {header("location: login.php");} ?> <div class="form1"> <div id="logo"><img src="images/citylogo.png" title="" border="0" /></div> <p>Please fill out the form below to update a new job opening. Once you have filled the form completely, check the correct radio button at the bottom of the form, for the appropriate update (full-time or part-time). If you wish to delete a opening that has been filled please click on view all openings and delete the opening that you want to delete. <form method="post" action="updatefulltime.php"> <table width="80%" border="0" cellspacing="5" cellpadding="0"> <tr><td colspan="2">Title & Department: <input name="department" type="text" value=" " size="50" maxlength="100" /></td></tr> <tr><td colspan="2">Pay Rate: <input name="pay" type="text" value=" " size="10" maxlength="4" /></td></tr> <tr><td colspan="2">Job #: <input name="jobnum" type="text" value=" " size="10" maxlength="10" /></td></tr> <tr><td colspan="2">Closing Date: <input name="dateclose" type="text" value=" " size="15" maxlength="15" /></td></tr> <tr><td colspan="2">Job Summary:</td></tr> <tr><td colspan="2"><textarea name="summary" cols="100" rows="10"></textarea></td></tr> <tr><td colspan="2">Example of work:</td></tr> <tr><td colspan="2"><textarea name="ex" cols="100" rows="10"></textarea></td></tr> <tr><td colspan="2">Equipment and Materials: </td></tr> <tr><td colspan="2"><textarea name="description" cols="100" rows="10"></textarea></td></tr> <tr><td colspan="2">Conditions:</td></tr> <tr><td colspan="2"><textarea name="conditions" cols="100" rows="10"></textarea></td></tr> <tr><td colspan="2">Education:</td></tr> <tr><td colspan="2"><textarea name="ed" cols="100" rows="10"></textarea></td></tr> <tr><td><input type="radio" name="searchType" checked="checked" value="fulltime" />full time<br /><input type="radio" name="searchType" value="parttime" />part time</td></tr> <tr><td colspan="2"><input name="submit" type="submit" value="submit" /><input type="reset" name="Reset" value="Clear Fields" /></td></tr> </table> </form> updatefulltime.php <?php //DISPLAYS USERNAME IF ALREADY LOGGED IN. if(isset($_SESSION["user_name"])) { print"<div style=\"float:right; border:1px solid $000000\"><p style=\"font-size: 10px\">You are logged in as: <br />"; print "".$_SESSION["user_name"]." "; if(isset($_SESSION["user_name"])) print"<a href=\"logout.php\">Logout!</a></p></div><br />"; } if(!($db = @ mysql_connect('localhost', 'xxxxx', 'pass'))) { print "Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time.".mysql_error(); } //select which database you want to edit mysql_select_db('edinburg_site'); $searchType = $_POST["searchType"]; $department=$_POST["department"]; $pay=$_POST["pay"]; $jobnum=$_POST["jobnum"]; $dateclose=$_POST["dateclose"]; $job_id=$_POST["job_id"]; $summary=$_POST["summary"]; $description=$_POST["description"]; $conditions=$_POST["conditions"]; $ex=$_POST["ex"]; $ed=$_POST["ed"]; if(empty($department) || empty($pay)) die ("<p>You can't leave the title field blanck.</p>"); else { if($searchType=="fulltime") { $query= "INSERT INTO fulltime VALUES ('{$department}','{$pay}','{$jobnum}','{$dateclose}',null, '{$summary}','{$description}','{$conditions}','{$ex}','{$ed}')"; $result = mysql_query($query) or die(mysql_error()); $job_id = mysql_insert_id(); print "You just have updated the Full-Time Employment Database. What do you want to do next? Please select from the following list."; print "<ul>"; print "<li><a href=\"fullemp.php\">View a updated Full-Time Job Postings</a></li>"; print "<li><a href=\"hrupdatefull.php\">Add another position</a></li>"; print "</ul>"; } else if($searchType == "parttime") { $query= "INSERT INTO parttime VALUES (null,'{$department}','{$pay}','{$jobnum}','{$dateclose}', '{$summary}','{$description}','{$conditions}','{$ex}','{$ed}')"; $result = mysql_query($query) or die(mysql_error()); $job_id = mysql_insert_id(); print "You just have updated the Part-Time Employment Database. What do you want to do next? Please select from the following list."; print "<ul>"; print "<li><a href=\"partime.php\">View a updated Part-Time Job Postings</a></li>"; print "<li><a href=\"hrupdatefull.php\">Add another position</a></li>"; print "</ul>"; } } session_start(); $_SESSION["user_id"] = $user_id; $_SESSION["ip_addr"] = $_SERVER["REMOTE_ADDR"]; $_SESSION["user_name"] = $user_name; print $user_id; print $user_name; ?> logout.php <?php session_start(); if(!isset($_SESSION["user_id"]) || !isset($_SESSION["ip_addr"])) die("invalid operation!!!<br /> please login first"); $user_id=$_SESSION["user_id"]; $ip_addr=$_SESSION["ip_addr"]; if ($ip_addr != $_SERVER["REMOTE_ADDR"]) die("invalid operation!!!<br /> please login first1111111111111111"); session_destroy(); header("Location: login.php"); ?>
-
thanks makes sense.
-
would it make a difference if they were all in one table hence having two tables. as far as performance etc...
-
Hello all, i am working on a project for job postings. right now i have my table structure with two tables. i have one table for the title, pay rate, job number, closing date and then i have another table for the description of the job as job summary, equipment and materials, condition of work enviornment, example of work, and education required. my question is would it be neccassary to have two tables or can i have all these info in one table? anyone??? Please help
-
why wouldn't it get the job_id from the fulltime table or pass it to the second query?
-
for some reason it does not get the job_id from the fulltime table
-
this is the echo INSERT INTO fulltime VALUES (' title','pay','jobq','date',null)insert into departments values(null,'','summary','equipment','conditions','example','education') the table structures are fulltime (department, pay, jobnum, dateclose, job_id) job_id is the primary key in this table second table departments (dept_id, job_id, summary, description, conditions, ex, ed) dept_id is the primary key in this table job_id is the foreign key from fulltime another thing i notice is that when i fill the form out and click submit, it inserts all info to both tables but the job_id doesnt go into the second table. i found out this by checking the tables on phpmyadmin
-
i did and still nothing. it echos out the info that i'm trying to submit but nothing when viewing the second table.
-
but it still doesn't update the second table.
-
Hello everyone, I am working on a project that requires updating two tables using a form. the two tables are related tables that need to be updated when submitting the form. my two tables are: fulltime (department, pay, jobnum, dateclose, job_id) departments (dept_id, job_id, summary, description, conditions, ex, ed) i have tried updating both tables using two querys but only the fulltime table get updated and nothing gets inserted into the department tables. this is my code: $department=$_POST["department"]; $pay=$_POST["pay"]; $jobnum=$_POST["jobnum"]; $dateclose=$_POST["dateclose"]; $job_id=$_POST["job_id"]; $dept_id=$_POST["dept_id"]; $summary=$_POST["summary"]; $description=$_POST["description"]; $conditions=$_POST["conditions"]; $ex=$_POST["ex"]; $ed=$_POST["ed"]; if(!isset($department) || empty($pay)) die ("<p>You can't leave the title field blanck.</p>"); if(!isset($department) || empty($pay)) die ("<p>You can't leave the story field field blanck.</p>"); //INSERTS INTO PROPER TABLES. $query= "INSERT INTO fulltime VALUES ('{$department}','{$pay}','{$jobnum}','{$dateclose}',NULL)"; $result = mysql_query($query) or die(mysql_error()); print $query; //insert into the department table $query = "insert into departments values(null,'{$job_id}','{$summary}','{$description}','{$conditions}','{$ex}','{$ed}')"; $result = mysql_query($query2) or die(mysql_error()); print $query; any help please what am i doing wrong? THanks in advance.