urgent help needed....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    urgent help needed....

    hi all,
    i want to pass a value from one php file to another popup window

    the value i am having is (in sample.php)
    Code:
    $value="<p><em><font style='background-color: #ccffff' face='Comic Sans MS' color='#ff0000' size='5'>pour faire suite &agrave; mon dernier mail sous une autre forme nous faisons en ce 
    moment des essais, merci de vous connecter , de renseigner votre profil et me faire parvenir 
    les documents que je vous ai demand&eacute; ou tout autres informations que vous voudriez voir 
    figurer sur le site.</font></em></p>";
    i want to show it in popup.php with the style,font,colo r as given above.
    i have tried the below code, it works well in IE, but not in firefox
    sample.php
    Code:
    <?php
    $value="<p><em><font style='background-color: #ccffff' face='Comic Sans MS' color='#ff0000' size='5'>pour faire suite &agrave; mon dernier mail sous une autre forme nous faisons en ce 
    moment des essais, merci de vous connecter , de renseigner votre profil et me faire parvenir 
    les documents que je vous ai demand&eacute; ou tout autres informations que vous voudriez voir 
    figurer sur le site.</font></em></p>";
    
    $value = str_replace("#", "", $value);
    $value = str_replace("'", "@", $value);
    $demo="Javascript:showme("."'popup.php?somevalue=".""".$value."');";
    
    //echo $demo;
    ?>
     <a href="<?php echo $demo?>">click JS</a>
    <script language="javascript">
    function showme(URL) {
    	
    	//alert(URL);
    	//window.open(URL);
    	window.open(URL,"target_blank",
    				"toolbar=0, location=0, statusbar=1, menubar=0, scrollbars=0, resizable=0, width=600, height=500");
    }
    </script>
    popup.php
    Code:
    <?php
    $demo= $_GET["somevalue"];
    $demo=stripslashes($demo);
    $demo=str_replace("'", "", $demo);
    $demo=str_replace('"', "", $demo);
    echo $demo;
    ?>
  • cassbiz
    New Member
    • Oct 2006
    • 202

    #2
    Originally posted by nirmalsingh
    hi all,
    i want to pass a value from one php file to another popup window

    the value i am having is (in sample.php)
    Code:
    $value="<p><em><font style='background-color: #ccffff' face='Comic Sans MS' color='#ff0000' size='5'>pour faire suite &agrave; mon dernier mail sous une autre forme nous faisons en ce 
    moment des essais, merci de vous connecter , de renseigner votre profil et me faire parvenir 
    les documents que je vous ai demand&eacute; ou tout autres informations que vous voudriez voir 
    figurer sur le site.</font></em></p>";
    i want to show it in popup.php with the style,font,colo r as given above.
    i have tried the below code, it works well in IE, but not in firefox
    sample.php
    Code:
    <?php
    $value="<p><em><font style='background-color: #ccffff' face='Comic Sans MS' color='#ff0000' size='5'>pour faire suite &agrave; mon dernier mail sous une autre forme nous faisons en ce 
    moment des essais, merci de vous connecter , de renseigner votre profil et me faire parvenir 
    les documents que je vous ai demand&eacute; ou tout autres informations que vous voudriez voir 
    figurer sur le site.</font></em></p>";
    
    $value = str_replace("#", "", $value);
    $value = str_replace("'", "@", $value);
    $demo="Javascript:showme("."'popup.php?somevalue=".""".$value."');";
    
    //echo $demo;
    ?>
     <a href="<?php echo $demo?>">click JS</a>
    <script language="javascript">
    function showme(URL) {
    	
    	//alert(URL);
    	//window.open(URL);
    	window.open(URL,"target_blank",
    				"toolbar=0, location=0, statusbar=1, menubar=0, scrollbars=0, resizable=0, width=600, height=500");
    }
    </script>
    popup.php
    Code:
    <?php
    $demo= $_GET["somevalue"];
    $demo=stripslashes($demo);
    $demo=str_replace("'", "", $demo);
    $demo=str_replace('"', "", $demo);
    echo $demo;
    ?>

    I noticed on line 9 that you have one too many double quotes, it should read

    Code:
    $demo="Javascript:showme("."'popup.php?somevalue="."".$value."');";
    Otherwise, the only thing that I can see is that you are using str_replace # to @ and I don't understand why.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      I have an alternate solution to your problem.

      Instead of passing this huge string throught the url using the GET protocol, why not pass it using POST?
      Main reason why it is better to pass values with POST is that url's have a max length (255 chars if memory serves) and GET has restriction on charactes it can pass on (#, ? and & for example will cause errors)

      I created this javascript to do what it is I think you are doing.
      Code:
      <?php
      if(isset($_POST['name']))
      	echo "<p>Value passed = ". $_POST['name'] ."</p>";
      ?>
      
      <script language="javascript">
      function open_url(url, fieldName, fieldValue)
      {
      	// Create new form element
      	var form = document.createElement("form");
      	form.setAttribute("target", "_blank");
      	form.setAttribute("method", "post");
      	form.setAttribute("action", url);
      	
      	// Create new input element
      	var field = document.createElement("input");
      	field.setAttribute("type", "text");
      	field.setAttribute("name", fieldName);
      	field.setAttribute("value", fieldValue);
      	
      	// Append input to form and form to body
      	form.appendChild(field);
      	document.body.appendChild(form);
      	
      	// submit form
      	form.submit();
      	
      	// Remove the form
      	document.body.removeChild(form);
      }
      </script>
      <a href="javascript: open_url('#', 'name', 'Atli');">Link</a>

      Comment

      • nirmalsingh
        New Member
        • Sep 2006
        • 218

        #4
        it works well. thanks a lot. but i want to open the second window in popup form. what should i do...?

        Comment

        • Velhari
          New Member
          • Sep 2006
          • 46

          #5
          Originally posted by nirmalsingh
          it works well. thanks a lot. but i want to open the second window in popup form. what should i do...?
          Hi,

          The solution for your problem is you have to create an object for window.open method in javascript.
          give like this,
          Code:
          popup = window.open(URL,"","toolbar=0, location=0, statusbar=1, menubar=0, scrollbars=0, resizable=0, width=600, height=500");
          popup.focus();
          Regards,
          VELMURUGAN.H
          Last edited by Velhari; Mar 14 '07, 08:00 AM. Reason: Mistake in syntax

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            You could try saving your data using a cokkie, open your php popup page using the javascript method 'window.open' and have your php popup page read the cookie.

            I'm also 99% sure you can save your data in the php $_SESSION array in your main page and have your popup page read it from there.

            Comment

            Working...