Results 1 to 5 of 5
  1. #1
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37

    New to PHP and Im officially stuck at this point and need help Please

    Long time since I have been here old friends, but I need your help today I have gotten stuck and need some code help and guidance. I have searched all over Google and I just cant seem to get this right or to work. To make sure we have a clear understanding I will include many details maybe someone can help me wrap this project up quickly (I have been trying to figure this out for days).

    I have the following page that displays a Project and the page name is editproject.asp and I want a user to select a file to upload in the form (It is provided on lines 194 thru 200 and this works). Issue on this page is when they click this I want it to pass the ID (This seens easiest way to pass the record ID) on line 190 to upload_file.php.


    Code:
    <head>
    <!-- #INCLUDE FILE="checklogin.asp" -->
    <!-- #INCLUDE FILE="common.asp" -->
    <title>Projects</title>
    </head>
    <!-- #INCLUDE FILE="nav.asp" -->
    <%
    filename = "projects.asp"
    filenameaction = "editproject.asp"
    keyname = "projects"
    tablename = "tblproj"
    'delete project
    if request.querystring("delete") = 1 then
     id = trim(request.querystring("id"))
     projrand = trim(request.querystring("projrand"))
     set Conn = server.createobject("adodb.connection")
     Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
     mySQL = "Delete FROM " & tablename & " where id = " & id & " and projrand = '" & projrand & "';"
     conn.execute(mySQL)
     closeconn()
     response.redirect(filename)
    end if
    'update project if form is sent.
    if request.form("formid") <> "" then
     id = request.form("formid")
     set Conn = server.createobject("adodb.connection")
     Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
     Set rs = Server.CreateObject("ADODB.RecordSet")
     mainSQL = "Select * from " & tablename & " where id = " & id & ";"
     'response.write mainsql
     rs.Open mainSQL, Conn, 1, 3
     if isdate(request.form("projdate")) then
      'empty checkbox is not passed so set to nothing by default first.
      rs("projprivate") = ""
      For Each strItem In Request.Form
       execute("rs(" & CHR(34) & strItem & CHR(34) & ") = request.form(" & CHR(34) & strItem & CHR(34) & ")")
         Next
      updated = 1
     else
      updated = 2
     end if
     rs.Update
     closers()
     closeconn()
     response.redirect("editproject.asp?id=" & id & "&updated=" & updated & "&time=" & time())
    end if
    id = request.querystring("id")
    showprojlastuser = Request.Cookies("stampedname")
    'display project
    set Conn = server.createobject("adodb.connection")
    Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
    Set rs = Server.CreateObject("ADODB.RecordSet")
    strSQL = "Select tblproj.id,tblproj.projname,tblproj.projdate,tblproj.projcontact,tblproj.projAddress,tblproj.projCity,tblproj.projState,tblproj.projZip,tblproj.projPhone,tblproj.projEmail,tblproj.projStyle,tblproj.projLeadTime,tblproj.projdesc,ProjEmpNotes,tblcat.category,tblstatus.status,tblproj.projorder,tblproj.projlastuser,tblproj.projlastdate,tblproj.projprivate,tblproj.projrand from tblproj,tblcat,tblstatus where tblproj.projcategory = tblcat.id AND tblproj.projstatus = tblstatus.id AND tblproj.id = " & id & " order by tblproj.projorder;"
    'Response.Write strSQL
    'response.end
    rs.Open strSQL, conn,1
    count = rs.recordcount
     if count <> 1 then
      closers()
      closeconn()
      response.redirect(filename)
     end if
    For fnum = 0 To rs.Fields.Count-1
     execute(rs.Fields(fnum).Name & " = rs(" & CHR(34) & rs.Fields(fnum).Name & CHR(34) & ")")
    Next
    closers()
    closeconn()
    'private setting checking
    if projprivate = "on" and Request.Cookies("stampedname") <> projlastuser then
     response.write "<p class='red'>This is a private project, you do not have permission to view it.</p>"
     response.end
    end if
    upd = request.querystring("updated")
    select case upd
    case "1"
     response.write "<p class='red'>updated</p>"
    case "2"
     response.write "<p class='red'>invalid date</p>"
    end select
    %>
    <form action="editproject.asp" method="post">
    <input type="submit" value="update" class="buttons">
    <br><br>
    <%=tablehead%>
    <tr>
     <td><strong>name</strong></td>
     <td valign="top"><input type="text" name="projname" value="<%= projname %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>date</strong></td>
     <td valign="top"><input type="text" name="projdate" value="<%= projdate %>" size="12">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Contact</strong></td>
     <td valign="top"><input type="text" name="projContact" value="<%= projContact %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Address</strong></td>
     <td valign="top"><input type="text" name="projAddress" value="<%= projAddress %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>City</strong></td>
     <td valign="top"><input type="text" name="projCity" value="<%= projCity %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>State</strong></td>
     <td valign="top"><input type="text" name="projState" value="<%= projState %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Zip</strong></td>
     <td valign="top"><input type="text" name="projZip" value="<%= projZip %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Phone</strong></td>
     <td valign="top"><input type="text" name="projPhone" value="<%= projPhone %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Email</strong></td>
     <td valign="top"><input type="text" name="projEmail" value="<%= projEmail %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Lead Type</strong></td>
     <td valign="top"><input type="text" name="projStyle" value="<%= projStyle %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td><strong>Lead Time</strong></td>
     <td valign="top"><input type="text" name="projLeadTime" value="<%= projLeadTime %>" size="45" maxlength="100">&nbsp;</td>
    </tr>
    <tr>
     <td valign="top"><strong>description</strong></td>
     <td valign="top"><textarea cols="45" rows="4" name="projdesc" class="formfont"><%= projdesc %></textarea>&nbsp;</td>
    </tr>
    <tr>
     <td valign="top"><strong>Employee Notes</strong></td>
     <td valign="top"><textarea cols="45" rows="4" name="projEmpNotes" class="formfont"><%= projEmpNotes %></textarea>&nbsp;</td>
    </tr>
    <tr>
     <td title="category"><strong>category</strong></td>
     <td valign="top">
     <select name="projcategory">
        <%call makecombo(category,"tblcat","category")%>
     </select>
     </td>
    </tr>
    <tr>
     <td title="status"><strong>status</strong></td>
     <td valign="top">
     <select name="projstatus">
        <%call makecombo(status,"tblstatus","status")%>
     </select>
     </td>
    </tr>
    <%
    If Session("Rights") = "1" THEN
    %>
    <tr>
     <td title="optional sort order critera"><strong>sort</strong></td>
     <td valign="top" title="optional sort order critera"><input type="text" name="projorder" value="<%= projorder %>" size="3">&nbsp;</td>
    </tr>
    <tr>
     <td title="only last user can view and edit"><strong>private</strong></td>
     <td valign="top" title="only last user can view and edit"><%=yesno(projprivate,"projprivate")%>&nbsp;</td>
    </tr>
    <%else%>
    <%
    end if
    %>
    <tr>
     <td title="date record last updated"><strong>last changed</strong></td>
     <td valign="top" title="date record last updated"><%= projlastdate %>&nbsp;</td>
    </tr>
    <tr>
     <td title="last user who updated the project"><strong>last user</strong></td>
     <td valign="top" title="last user who updated the project"><%= projlastuser %>&nbsp;</td>
    </tr>
    </table>
    <input type="hidden" name="projlastdate" value="<%=now()%>">
    <input type="hidden" name="projlastuser" value="<%=showprojlastuser%>">
    <input type="hidden" name="projrand" value="<%=randgen()%>">
    <input type="hidden" name="formid" value="<%=id%>">
    <input type="submit" value="update" class="buttons">
    </form>
    <br />
    <form action="upload_file.php" method="post"
     enctype="multipart/form-data">
     <label for="file">Filename:</label>
     <input type="file" name="file" id="file" />
     <br />
     <input type="submit" name="Submit" value="Upload" />
     </form>
    
    <%
    If Session("Rights") = "1" THEN
    %>
    <p><a href="editproject.asp?delete=1&id=<%=id%>&projrand=<%=projrand%>" onclick="return confirm('Are you sure you want to delete?')" class='red'>delete the project</a></p>
    <%
    Else
    End if
    %>
    Now we have arrived at Upload_file.php which is mainly to upload the file currently to a directory (THis is only way I could get this to work) but I want it to write the file name with hyperlink path http://fencemstersunlimited.com/uplo...older/FILENAME to the record ID we passed from the previous page editproject.asp. The database name is projectdb.mdb stored in /fpdb/project.mdb and the table name is tblproj and the field is projestimate. After all this is done instead of how it currently just display the file was uploaded I want to redirect back to editproject.asp and open the record back up refreshed with the new data and dispaly "Filename uploaded Successfully" in Red so that you know it was a success instead of the file data.

    Here is the code for the Upload_file.php

    Code:
    <?php
     if ((($_FILES["file"]["type"] == "application/pdf")
     || ($_FILES["file"]["type"] == "image/jpeg")
     || ($_FILES["file"]["type"] == "image/pjpeg"))
     && ($_FILES["file"]["size"] < 20000))
       {
       if ($_FILES["file"]["error"] > 0)
         {
         echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
         }
       else
         {
         echo "Upload: " . $_FILES["file"]["name"] . "<br />";
         echo "Type: " . $_FILES["file"]["type"] . "<br />";
         echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
         echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
     
        if (file_exists("../upload/uploadfolder/" . $_FILES["file"]["name"]))
           {
           echo $_FILES["file"]["name"] . " already exists. ";
           }
         else
           {
           move_uploaded_file($_FILES["file"]["tmp_name"],
           "../upload/uploadfolder/" . $_FILES["file"]["name"]);
           echo "Stored in: " . "../upload/uploadfolder/" . $_FILES["file"]["name"];
           }
         }
       }
     else
       {
       echo "Invalid file";
       }
     ?>
    Thank You in advance for any help with the code provided.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    This is an Access forum site and programming would be macros or VBA.

    You might try a site with PHP forum. Look at http://www.developerbarn.com/communi...evelopment.20/
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    by far the best php forum is:

    http://www.phpfreaks.com/forums/

    but I'm biased!

  4. #4
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    Quote Originally Posted by June7 View Post
    This is an Access forum site and programming would be macros or VBA.

    You might try a site with PHP forum. Look at http://www.developerbarn.com/communi...evelopment.20/
    Thanks I will check it out but I figured since this forum is about Access and has programming forum section and I have got answers and seen others get answers about asp that php would apply as well. I guess this is meant for some other type of Programming?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    The focus here is Access and that means macros and VBA.

    If someone also has PHP (or ASP or HTML or Java, etc) knowledge and wants to respond, lucky you. But your chances for solution might be better on forum with PHP focus.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can someone point to to a tutorial
    By Poker4dbs in forum Forms
    Replies: 8
    Last Post: 08-05-2011, 12:30 PM
  2. Get Subform to point at first record
    By jpkeller55 in forum Forms
    Replies: 3
    Last Post: 09-08-2010, 07:18 PM
  3. Items at reorder point
    By MFS in forum Queries
    Replies: 2
    Last Post: 04-01-2010, 11:43 AM
  4. What is the point of different modules?
    By cowboy in forum Programming
    Replies: 3
    Last Post: 03-29-2010, 10:43 PM
  5. Point of Sales Application
    By chico_yallin in forum Access
    Replies: 1
    Last Post: 06-23-2007, 05:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums