Loading ...
Sorry, an error occurred while loading the content.

Re: [phpXperts] Simple PHP Syntax Question

Expand Messages
  • Manish
    Hi, Try with the following: echo click here to download Non_Disclosure Agreement
    Message 1 of 6 , Oct 15, 2008
    • 0 Attachment
      Hi,
      Try with the following:

      echo '<a
      href="http://www.joshuane il.com/hir/ scripts/results/'.$fdf_file.' ">click
      here to download Non_Disclosure Agreement</a>' ;

      It should work.

      Thanks & Regards,
      Manish.

      --- On Wed, 10/15/08, josh@... <josh@...> wrote:
      From: josh@... <josh@...>
      Subject: [phpXperts] Simple PHP Syntax Question
      To: phpexperts@yahoogroups.com
      Date: Wednesday, October 15, 2008, 11:14 AM

      Hello,

      I am having a problem with my PHP script. This is surely a simple syntax
      error and I have gone almost crossed eyed trying several things to get it
      to work. The problem is with the following line of PHP:

      ------------ --------- --------- --------- --------- --------- -

      echo '<a
      href="http://www.joshuane il.com/hir/ scripts/results/'.$fdf_file, '>click
      here to download Non_Disclosure Agreement</a> ';

      ------------ --------- --------- --------- --------- --------- -

      The problem is that it is not generating the hyperlink for users to click
      on in Internet Explorer. The code is working fine in Mozilla Firefox but I
      need to get it to work in Internet Explorer.

      Below is the entire script from which the line of code from above is
      located. The line of code from above is not too far from the bottom of the
      following script. Please check it out and let me know if you have any
      suggestions.

      ------------ --------- --------- --------- --------- --------- -

      <?php
      // check that a form was submitted
      if(isset($_POST) && is_array($_POST) && count($_POST) ){
      // we will use this array to pass to the createFDF function
      $data=array( );

      // This displays all the data that was submitted. You can
      // remove this without effecting how the FDF data is generated.
      echo'<pre>POST '; print_r($_POST) ;echo '</pre>';

      if(isset($_POST[ 'TEXT1']) ){
      // the name field was submitted
      $pat='`[^a-z0- 9\s]+$`i' ;
      if(empty($_POST[ 'TEXT1']) || preg_match($ pat,$_POST[ 'TEXT1']) ){
      // no value was submitted or something other than a
      // number, letter or space was included
      die('Invalid input for TEXT1 field.');
      }else{
      // if this passed our tests, this is safe
      $data['TEXT1' ]=$_POST[ 'TEXT1'];
      }

      if(!isset($_ POST['TEXT2' ])){
      // Why this? What if someone is spoofing form submissions
      // to see how your script works? Only allow the script to
      // continue with expected data, don't be lazy and insecure ;)
      die('You did not submit the correct form.');
      }

      // Check your data for ALL FIELDS that you expect, ignore ones
      you
      // don't care about. This is just an example to illustrate, so I
      // won't check anymore, but I will add them blindly (you don't
      want
      // to do this in a production environment) .
      $data['TEXT3' ]=$_POST[ 'TEXT3'];
      $data['TEXT4' ]=$_POST[ 'TEXT4'];
      $data['TEXT5' ]=$_POST[ 'TEXT5'];

      // I wanted to add the date to the submissions
      $data['TEXT13' ]=date('Y- m-d H:i:s');

      // if we got here, the data should be valid,
      // time to create our FDF file contents

      // need the function definition
      require_once 'createFDF.php' ;

      // some variables to use

      // file name will be <the current timestamp>.fdf
      $fdf_file=time( ).'.fdf';

      // the directory to write the result in
      $fdf_dir=dirname( __FILE__) .'/results' ;

      // need to know what file the data will go into
      $pdf_doc='http://www.joshuane il.com/hir/ pdf/HIR_NDA. pdf';

      // generate the file content
      $fdf_data=createFDF ($pdf_doc, $data);

      // this is where you'd do any custom handling of the data
      // if you wanted to put it in a database, email the
      // FDF data, push ti back to the user with a header() call, etc.

      // write the file out
      if($fp=fopen( $fdf_dir. '/'.$fdf_ file,'w') ){
      fwrite($fp,$ fdf_data, strlen($fdf_ data));
      echo $fdf_file,' written successfully. ';
      echo '<br>';
      echo '<a
      href="http://www.joshuane il.com/hir/ scripts/results/'.$fdf_file, '>click
      here to download Non_Disclosure Agreement</a> ';
      }else{
      die('Unable to create file: '.$fdf_dir.' /'.$fdf_file) ;
      }
      fclose($fp);
      }
      }else{
      echo 'You did not submit a form.';
      }
      ?>

      ____________ _________ _________ _________ _________ _________ _

      Thanks for all your help. If you have any questions or require any
      additional information from me concerning this script please feel free to
      send me an email.

      Thank you all in advance for your assistance.

      Thanks,
      Josh
      josh@joshuaneil. com
      http://www.joshuane il.com


    • Naseer Ahmad
      Hi, here your correct syntax echo click here to download Non_Disclosure
      Message 2 of 6 , Oct 15, 2008
      • 0 Attachment
        Hi,

        here your correct syntax

        echo "<a href=\"http://www.joshuane il.com/hir/ scripts/results/".$fdf_file."\">click
        here to download Non_Disclosure Agreement</a>";

        try to use double qoutes....

        Naseer Ahmad Mughal
        Project Manager
        Visdom Soft
        Islamabad, Pakistan
        Voice: PK: +92 (0)333 5544937
        UK:  +44 871 572 7060
        E-mail: visdomsoft@gmail. com
        URL: http://www.visdomsoft.com
        http://www.naseerahmad.com (Personal Blog)
        Jaxtr ID: http://www.jaxtr. com/naseermughal

        --- On Thu, 10/16/08, Mynul Islam <mynul9280@...> wrote:
        From: Mynul Islam <mynul9280@...>
        Subject: Re: [phpXperts] Simple PHP Syntax Question
        To: phpexperts@yahoogroups.com
        Date: Thursday, October 16, 2008, 9:12 AM

        Surely syntax error -
        ------------ --------
        echo '<a
        href="http://www.joshuane il.com/hir/ scripts/results/'.$fdf_file,'>click here to download Non_Disclosure Agreement</a>';
        ------------ --------- --
        check the Starting ECHO it is a single quote and it ends near the concatenation of $fdf_file which should not. then again it starts and ends outside. Moreover your href starts with double quote but never ends!!!

        Simply remove these bugs and the code is fine!




        On Thu, Oct 16, 2008 at 12:14 AM, <josh@joshuaneil. com> wrote:

        Hello,

        I am having a problem with my PHP script. This is surely a simple syntax
        error and I have gone almost crossed eyed trying several things to get it
        to work. The problem is with the following line of PHP:

        ------------ --------- --------- --------- --------- --------- -

        echo '<a
        href="http://www.joshuane il.com/hir/ scripts/results/'.$fdf_file,'>click
        here to download Non_Disclosure Agreement</a>';

        ------------ --------- --------- --------- --------- --------- -

        The problem is that it is not generating the hyperlink for users to click
        on in Internet Explorer. The code is working fine in Mozilla Firefox but I
        need to get it to work in Internet Explorer.

        Below is the entire script from which the line of code from above is
        located. The line of code from above is not too far from the bottom of the
        following script. Please check it out and let me know if you have any
        suggestions.

        ------------ --------- --------- --------- --------- --------- -

        <?php
        // check that a form was submitted
        if(isset($_POST) && is_array($_POST) && count($_POST) ){
        // we will use this array to pass to the createFDF function
        $data=array( );

        // This displays all the data that was submitted. You can
        // remove this without effecting how the FDF data is generated.
        echo'<pre>POST '; print_r($_POST) ;echo '</pre>';

        if(isset($_POST['TEXT1'])){
        // the name field was submitted
        $pat='`[^a-z0-9\s] +$`i';
        if(empty($_POST['TEXT1']) || preg_match($ pat,$_POST['TEXT1'])){
        // no value was submitted or something other than a
        // number, letter or space was included
        die('Invalid input for TEXT1 field.');
        }else{
        // if this passed our tests, this is safe
        $data['TEXT1']=$_POST['TEXT1'];
        }

        if(!isset($_ POST['TEXT2'])){
        // Why this? What if someone is spoofing form submissions
        // to see how your script works? Only allow the script to
        // continue with expected data, don't be lazy and insecure ;)
        die('You did not submit the correct form.');
        }

        // Check your data for ALL FIELDS that you expect, ignore ones
        you
        // don't care about. This is just an example to illustrate, so I
        // won't check anymore, but I will add them blindly (you don't
        want
        // to do this in a production environment) .
        $data['TEXT3']=$_POST['TEXT3'];
        $data['TEXT4']=$_POST['TEXT4'];
        $data['TEXT5']=$_POST['TEXT5'];

        // I wanted to add the date to the submissions
        $data['TEXT13']=date('Y-m-d H:i:s');

        // if we got here, the data should be valid,
        // time to create our FDF file contents

        // need the function definition
        require_once 'createFDF.php';

        // some variables to use

        // file name will be <the current timestamp>.fdf
        $fdf_file=time( ).'.fdf';

        // the directory to write the result in
        $fdf_dir=dirname( __FILE__) .'/results';

        // need to know what file the data will go into
        $pdf_doc='http://www.joshuane il.com/hir/ pdf/HIR_NDA. pdf';

        // generate the file content
        $fdf_data=createFDF ($pdf_doc, $data);

        // this is where you'd do any custom handling of the data
        // if you wanted to put it in a database, email the
        // FDF data, push ti back to the user with a header() call, etc.

        // write the file out
        if($fp=fopen( $fdf_dir.'/'.$fdf_file,'w')){
        fwrite($fp,$ fdf_data, strlen($fdf_ data));
        echo $fdf_file,' written successfully.';
        echo '<br>';
        echo '<a
        href="http://www.joshuane il.com/hir/ scripts/results/'.$fdf_file,'>click
        here to download Non_Disclosure Agreement</a>';
        }else{
        die('Unable to create file: '.$fdf_dir.'/'.$fdf_file);
        }
        fclose($fp);
        }
        }else{
        echo 'You did not submit a form.';
        }
        ?>

        ____________ _________ _________ _________ _________ _________ _

        Thanks for all your help. If you have any questions or require any
        additional information from me concerning this script please feel free to
        send me an email.

        Thank you all in advance for your assistance.

        Thanks,
        Josh
        josh@joshuaneil. com
        http://www.joshuane il.com




        --
        With Thanks
        "MYNUL"

      • Sabrina Akter
        Hello Josh, bellow line is yours. ... 1. * http://www.joshuaneil.com/hir/scripts/results/ *= starting tag and ending tag must be same*.* 2. *$**fdf_file, =
        Message 3 of 6 , Oct 16, 2008
        • 0 Attachment
          Hello Josh,
          bellow line is yours.

          echo '<a href="http://www.joshuaneil.com/hir/scripts/results/'.$fdf_file,'>click here to download Non_Disclosure Agreement</a>';

          ----------------------------------------------------------


          1. "http://www.joshuaneil.com/hir/scripts/results/' => starting tag and ending tag must be same.
          2. $fdf_file,' => i really dont know why u use (comma sign) ',' ?? it should be (dot sign ) '.' after variable,as u are adding another string statement.

          --
          Thanks
          -----------------
          Sabrina Akter  |  System Developer
          Email: lizzeelike@...
          Dhaka, Bangladesh
        Your message has been successfully submitted and would be delivered to recipients shortly.