S
simbu

  • Jan 4, 2013
  • Joined Oct 7, 2012
  • Ashley Sheridan;11021615 wrote:

    What is document format? .doc, .rtf, .pdf, .odt are all document formats.

    Like I said, you can't force an open/save dialogue box.

    .doc files..

    Is there any other way to do like that type?(Open or save as dialog box..)

    If u know means,tell me how to do it...

    thanks in advance,
    simbu.

    • Ashley Sheridan;11021609 wrote:

      You can't force the open/save dialogue on browsers, you can only force a download. If you leave out the Content-Disposition header the browser will perform its default action. You've not said what format this file is in, so it might behave differently for different people:

      • PDF - if the browser has a PDF viewer it might open in the browser. Chrome has one built in, Adobe provide a plugin for browsers on Mac/Windows, but a user may not have that OS or the Adobe Reader (I personally don't as I prefer a reader with less security holes and less of a tendency to bug me about updates every day)

      • MS Office document - There is a plugin for some Windows browsers that allows these to be opening in the browser, but it's not very popular

      • OpenOffice/LibreOffice document - plugins do exist for major browsers on Mac/Linux/Windows, but they aren't widespread

      • RTF - I don't know first-hand of any browser which handles these files, perhaps one of the Office plugins would

      Personally I'd let the browser do its thing. Bear in mind that people spend time setting up their web browsers the way they like, so to try and make it do something other than what they've set as the default is not always the best idea.

      Thanks for ur reply...

      My file contains document format.When i click on the link first it should open a dialog box in that open or save as button as like that....

      • Hello,

        I want to open a file from database folder based on the link.If the user wants to view the particular file means and when they clicks on that particulat link it should ask ,Do u want to open or save? Like this....

        But i created direct download by using link.Its works fine.

        So if anyone knows let me know...

        This is my download file.

        [/code]
        <?php

        if (isset($GET['resume']) && basename($GET['resume']) == $_GET['resume']) {

        $filename = $_GET['resume'];

        } else if(isset($GET['sdoc']) && basename($GET['sdoc']) == $GET['sdoc']) {
        $filename = $
        GET['sdoc']; }

        else {
        $filename = NULL; }

        // define error message

        $err = '<p style="color:#990000">Sorry, the file you are requesting is unavailable.</p>';

        if (!$filename) {

            // if variable $filename is NULL or false display the message
        
            echo $err;
        
        } else {
        
            // define the path to your download folder plus assign the file name
        
            $path = 'documents/'.$filename;
        
            // check that file exists and is readable
        
            if (file_exists($path) && is_readable($path)) {
        
                // get the file size and send the http headers
        
                $size = filesize($path);
        
                header('Content-Type: application/octet-stream');
        
                header('Content-Length: '.$size);
        
                header('Content-Disposition: attachment; filename='.$filename);
        
                header('Content-Transfer-Encoding: binary');
        
        
        
        
                $file = @ fopen($filename, 'r');
        
                if ($file) {
        
                    // stream the file and exit the script when complete
        
                    fpassthru($file) or die(mysql_error());
        
                    exit;
        
                } else {
        
                    echo $err;
        
                }
        
            } else {
        
                echo $err;
        
            }
        
        }

        ?>

        • Hello ,

          Can anyone tell me how to destroy the session when the user closes the tab ?

          advance thanks.

          • hello,

            I want to create a forgot password in my login page.

            This is my codings but i am getting error.
            The erroe is. "no such login in the system. please try again..

            forgot_password.php

            <?php
            if(isset($_POST['submit']))
            {
            mysql_connect("localhost", "root", "") or die(mysql_error());
            mysql_select_db("recruiter") or die(mysql_error());

            $id = $_POST['id'];
            }
            $sql="SELECT * FROM login WHERE id='.$id.'";
            $r = mysql_query($sql);
            if(!$r) {

            $err=mysql_error();

            print $err;

            exit();
            }

            if(mysql_affected_rows()==0)
            {

            print "no such login in the system. please try again.";

            exit();
            }
            else {

            $row=mysql_fetch_array($r);

            $password=$row<"password">;

            $email=$row<"email">;

            $subject="your password";

            $header="from:you@yourdomain.com";

            $content="your password is ".$password;

            mail($email, $subject, $row, $header);

            print "An email containing the password has been sent to you";

            }
            ?>

            for.php

            <html>
            <head>
            </head>
            <body>
            <form name="forgot" method="post" action="forgot_password.php">
            Enter ur id:
            <input name="id" type="text" value="" />

            <input type="submit" name="submit" value="submit"/>
            <input type="reset" name="reset" value="reset"/>
            </form>

            </body>
            </html>

            If anyone knows let me know the solution.

            • simbu;11019145 wrote:

              Once if i click the download link it shows all the resume from resumes folder.But i want to download a particular resume coresponding to candidate id.

              Here is my codings.

              dow.php:

              <?php

              mysql_connect("localhost","root","");
              mysql_select_db("sample");

              if(isset($_GET['id']))

              {
              $id=intval($_GET['id']);
              $query = "SELECT file FROM testing WHERE id=$id";
              $result = mysql_query($query) or die('Error, query failed');
              list($file, $type) = mysql_fetch_array($result);
              header("Content-Disposition: attachment; filename='$file'");
              header("Content-length: $size");
              header("Content-type: $type");
              echo $file;

              exit;

              }

              ?>

              <html>
              <head>
              <title>Download a resume</title>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
              </head>
              <body>

              <?php
              $query = "SELECT file FROM testing ";
              $result = mysql_query($query) or die('Error, query failed');
              if(mysql_num_rows($result) == 0)
              {
              echo "Database is empty <br>";
              }else{
              while(list($file) = mysql_fetch_array($result))
              {
              ?>
              <a href="download.php?id=<?php echo $id ?>"><?php echo $file ?></a> <br/>

              <?php
              }
              }
              ?>

              </body>

              </html>

              download.php:

              <?php
              if(isset($_GET['id']))
              {
              // if id is set then get the file with the id from database

              mysql_connect("localhost","root","");
              mysql_select_db("sample");

              $id = $_GET['id'];
              $query = "SELECT file FROM testing WHERE id='$id'";

              $result = mysql_query($query);
              list($file) = mysql_fetch_array($result) or die(mysql_error());

              header("Content-length: '$file'");
              header("Content-type: application/msword");
              header("Content-Disposition: attachment; filename=\'$file\'");
              echo "$file";

              exit;
              }

              ?>

              • Weedpacket;11019139 wrote:

                ...and what is the problem you're having?

                Once if i click the download link it shows all the resume from resumes folder.But i want to download a particular resume coresponding to candidate id.

                • bradgrafelman;11019051 wrote:

                  What does "shows all resumes in the resumes folder" mean? For example, does the link take you to a standard directory index/listing that shows a list of files? Also, what does the resulting HTML markup look like when that code is executed?

                  Once i click the download link it goes to resumes folder and displays all the resumes.But if click the download link it should be download the corresponding resume from resumes folder.

                  • Hello,

                    I need to download a single resume corresponding to id and here is my codings.

                    <?php

                    mysql_connect("localhost","root","");
                    mysql_select_db("sample");

                    ?>

                    <?php
                    if(isset($GET['id']))
                    {
                    $id = $
                    GET['id'];
                    $query = mysql_query("SELECT file FROM testing WHERE id='$id' ");
                    $row = mysql_fetch_array($query);
                    }
                    ?>
                    <a href='resumes/'<?= $row['file'] ?>Download</a>

                    it works,but it shows all the resumes in the resumes folder.but i need to download only the corresponding resume.

                    If anyone knows, let me know.

                    • Hello,

                      Its a big explanation.Give me ur mail id i will tell u everything in that.

                      • Hello,

                        I am creating a one sample registration form.In that i want to display the username in last column as a posted by at that time when i am viewing the datas from database the username should be displayed.

                        name | email | phone | postedby

                        If the user arun has register means it will show posted by arun like that.

                        So can u able to tell me how to do it?

                        • Weedpacket;11018695 wrote:

                          You don't need this. Remove it. Use the [font=monospace]$_SESSION[/font] array instead.

                          That means [font=monospace]$_SESSION['name'][/font] only contains the first letter. The mistake is in whatever code you use to set its value.

                          At a guess you have the name in a string but you're trying to access it as if it were in an array. But that's only a guess. You know better what you're doing than I do.

                          Thank u so much....🙂 Got it.

                          • Hello,

                            I want to display the username after logging in .Right now i am getting only the first letter of my logging name.

                            I want to display the full name i.e username.

                            Here is my session code.

                            In login.php

                            <?
                            session_start();
                            session_register('name');
                            ?>

                            In next page:

                            <?php
                            session_start():
                            $s_name=$_SESSION['name'];
                            ?>
                            Hello <?php echo $s_name; ?>

                            I am getting only the first letter of my logging user.

                            • bradgrafelman;11017405 wrote:

                              One way:

                              Options +MultiViews

                              See MultiViews in the Apache docs for more info on what that does.

                              Now there is no change in my url.I am getting with .php or .html extensions.

                              Could somebody tell me whats the problem?

                              regards,
                              simbu.

                              • hello,

                                I want to hide the extension file in address bar.

                                Example: www.aaa.com/index.php and it should be like this www.aaa.com/index

                                Please let me know anyone waiting for ur response..

                                This is my .htaccess file in website

                                RewriteEngine on

                                RewriteCond %{REQUEST_FILENAME} !-d

                                RewriteCond %{REQUEST_FILENAME}.php -f

                                RewriteRule (.*)$ $1.php

                                regards,
                                simbu.

                                • Weedpacket;11016763 wrote:

                                  When posting code, please use the forum markup tags described in the FAQs to mark up your code to make it readable.

                                  Find the place in your code that produces the error message, and work out what has to happen for that bit of code to be reached. That should tell you something about what is wrong. (Of course, if it were well-written, the error message itself would have some information about what the error was.)

                                  When i run this program i displays output as - Error!

                                  But i want to edit the data from database.

                                  thanks.

                                  • Hello friends,

                                    I am creating a registration form page.In that i have to edit and delete.So in edit page..I am getting the error.Here I will post the codings and let me know my queries...

                                    If i am run the edit.php i am getting this error -" Error! "

                                    <?php
                                    
                                     function renderForm($id, $name, $email,$error)
                                     {
                                     ?>
                                    
                                     <html>
                                     <head>
                                     <title>Edit Record</title>
                                     </head>
                                     <body>
                                     <?php 
                                     // if there are any errors, display them
                                     if ($error != '')
                                     {
                                     echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
                                     }
                                     ?> 
                                    
                                     <form action="" method="post">
                                     <input type="hidden" name="id" value="<?php echo $id; ?>"/>
                                     <div>
                                     <p><strong>ID:</strong> <?php echo $id; ?></p>
                                     <strong>Your Name: *</strong> <input type="text" name="name" value="<?php echo $name; ?>"/><br/>
                                     <strong>email: *</strong> <input type="text" name="email" value="<?php echo $email; ?>"/><br/>
                                     <p>* Required</p>
                                     <input type="submit" name="submit" value="Submit">
                                     </div>
                                     </form> 
                                     </body>
                                     </html> 
                                     <?php
                                     }
                                    
                                    
                                    
                                     // connect to the database
                                     include('dbadmin.php');
                                    
                                     // check if the form has been submitted. If it has, process the form and save it to the database
                                     if (isset($_POST['submit']))
                                     { 
                                     // confirm that the 'id' value is a valid integer before getting the form data
                                     if (is_numeric($_POST['id']))
                                     {
                                     // get form data, making sure it is valid
                                     $id = $_POST['id'];
                                     $name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
                                      $email= mysql_real_escape_string(htmlspecialchars($_POST['email']));
                                    
                                     if ($name == '' ||  $email == '')
                                     {
                                     // generate error message
                                     $error = 'ERROR: Please fill in all required fields!';
                                    
                                     //error, display form
                                     renderForm($id, $name, $email,$error);
                                     }
                                     else
                                     {
                                     // save the data to the database
                                     mysql_query("UPDATE login SET name='$name',email='$email' WHERE id='$id'")
                                     or die(mysql_error()); 
                                    
                                    
                                     header("Location: viewrec.php"); 
                                     }
                                     }
                                     else
                                     {
                                    
                                     echo 'Error!';
                                     }
                                     }
                                     else
                                    
                                     {
                                    
                                     if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
                                     {
                                     // query db
                                     $id = $_GET['id'];
                                     $result = mysql_query("SELECT * FROM login WHERE id=$id")
                                     or die(mysql_error()); 
                                     $row = mysql_fetch_array($result);
                                    
                                    
                                     if($row)
                                     {
                                    
                                    
                                     $name = $row['name'];
                                     $email = $row['email'];
                                    
                                     renderForm($id, $name,$email, '');
                                     }
                                     else
                                     // if no match, display result
                                     {
                                     echo "No results!";
                                     }
                                     }
                                     else
                                    
                                     {
                                     echo 'Error!';
                                     }
                                     }
                                    ?>
                                    

                                    thanks..

                                    • Ashley Sheridan;11016587 wrote:

                                      Well, as you've not told us anything about the registration form, the best help I can offer is that you can do it with a text editor and the copy/paste commands.

                                      Thanks for ur response,

                                      I created the registration form and as well as email verification.Thats why i didnt post anything.

                                      thanks,
                                      simbu.

                                      • Hello,

                                        I want to check the email validate from database in the same registration form?

                                        Here is my coding....It checks from database and shows the result but i need to include this coding in the registration form.Let me know how to do?

                                        <?php
                                        // connection to MySQL server
                                        mysql_connect('localhost','','');
                                        mysql_select_db('han');

                                        // User input
                                        $email = $_POST["email"];

                                        // Construct and run query.
                                        $sql = ("SELECT email FROM form WHERE email='$email'")or die(mysql_error());
                                        $result = mysql_query($sql);

                                        // If there is a user, log them in.
                                        if(mysql_num_rows($result) > 0)
                                        {
                                        $_SESSION['login'] = true;

                                        echo "Email already exist , please try different one";
                                        }
                                        else
                                        die('Email not in use u can use it');
                                        ?>

                                        thanks,
                                        simbu.

                                        • Ashley Sheridan;11016411 wrote:

                                          What have you tried already?

                                          Thanks yaar, I created the sample search engine for my website.

                                          Once again thanks for ur help.

                                          regards,
                                          simbu.