0

i am trying to print the value of $ss. but it say 'qty' is undifine on line($ss = $_post['qty'];).

index.php

<?php
echo"
<form  method='post' action='index.php'>

   <input type='text'  name='qty' />

    <button type='submit' id='opener01'  name='b1'>submit</button>

</form>";



echo"
<div id='dialog01' title='ccc'> ";
                $ss = $_post['qty'];
                echo"$s;

    echo"
    </div>";
?>

jquery.js

$( "#dialog01" ).dialog({
    autoOpen: false, 
    modal: true,
    buttons: {
        "option1": function() {
            $( this ).dialog( "close" );
         },
        "exit": function() {
            $( this ).dialog( "close" );
        }
    }
});
$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      return false;
}); 

Edited by hwoarang69

5
Contributors
15
Replies
17
Views
4 Years
Discussion Span
Last Post by diafol
Featured Replies
  • $_post is incorrect as always needs to be in upper case so change to $_POST Read More

  • This code can not display the value of $ss, because you are echoing $s instead. Please rectify that first. Read More

  • Hi Webville, I think you mistook the second 's' character as a dollar sign. Hi Hwoarang, Simplypixie was right, you should make the `$_post` all-caps. Change it to `$_POST` ERRATA: Hi Webville, you were right. LOL Hoarang, you are also echoing the wrong variable. See line 15 and 16 of … Read More

  • In which case your echo statement is incorrect, try $ss = $_POST['qty']; echo "<div id='dialog01' title='ccc'>".$ss."</div>"; Read More

  • 1
    diafol 3,720   4 Years Ago

    echo "<div id='dialog01' title='ccc'> "; $ss = $_post['qty']; echo "$ss; //WHY THE " ? No need echo "</div>"; Also on page load, you'll get an error as the $_POST['qty'] won't exist yet as you've not submitted the form. Use and 'if': if(isset($_POST['qty'])){ $ss = $_POST['qty']; //escape or validate as required … Read More

1

This code can not display the value of $ss, because you are echoing $s instead. Please rectify that first.

2

Hi Webville, I think you mistook the second 's' character as a dollar sign.

Hi Hwoarang,
Simplypixie was right, you should make the $_post all-caps. Change it to $_POST

ERRATA:
Hi Webville, you were right. LOL
Hoarang, you are also echoing the wrong variable. See line 15 and 16 of your sample.

Edited by gon1387

0

ops sorry i made a mistake when i was type it on daniweb.com.

on my code i have POST caps and echo"$s" is echo"$ss"

1

In which case your echo statement is incorrect, try

$ss = $_POST['qty'];
echo "<div id='dialog01' title='ccc'>".$ss."</div>";
1
echo "<div id='dialog01' title='ccc'> ";
$ss = $_post['qty'];
echo "$ss;  //WHY THE " ? No need 
echo "</div>";

Also on page load, you'll get an error as the $_POST['qty'] won't exist yet as you've not submitted the form. Use and 'if':

if(isset($_POST['qty'])){
    $ss = $_POST['qty']; //escape or validate as required
    echo "<div id='dialog1 title='cc'>$ss</div>";
}

Or looking at your ajax - you probably need the div to be present on page load:

$ss = (isset($_POST['qty']) ? $_POST['qty'] : 0;
echo "<div id='dialog1 title='cc'>$ss</div>";

Edited by diafol

0

ahh i c the problem. in order for $ss has a value, the page need to refesh/submit. and bc iam using ajax to open dialog box thats why $ss has no value yet.

is there a way for me to send value in div dialog box?

//dialog box - prints "no post"

echo"
<div id='dialog01' title='ccc'> ";
       if(isset($_POST['qty'])){        
               $ss = $_post['qty'];
                echo $ss;
                }
                else
                {
                echo"NO POST";
               }

    echo"
    </div>";

Edited by hwoarang69

0

nope not solved. let me repost all the code i have so far

inside div dialog01 i want to echo $ss. but its echo out "no POST". i am not sure how can i echo the value of qty.

index.php

    <?php
    echo"
    <form  method='POST' action='index.php'>

       <input type='text'  name='qty' />

        <button type='submit' id='opener01'  name='b1'>submit</button>

    </form>";

 echo"
<div id='dialog01' title='ccc'> ";
       if(isset($_POST['qty'])){        
               $ss = $_post['qty'];
                echo $ss;
                }
                else
                {
                echo"NO POST";
               }

    echo"
    </div>";
    ?>

jquery.php

$( "#dialog01" ).dialog({
    autoOpen: false, 
    modal: true,
    buttons: {
        "option1": function() {
            $( this ).dialog( "close" );
         },
        "exit": function() {
            $( this ).dialog( "close" );
        }
    }
});
$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      return false;
}); 

Edited by hwoarang69

0

Change this:

$ss = $_post['qty'];

to this:

$ss = $_POST['qty'];

Simplypixie and gon1387 mentioned this.

0

no

inside div dialog01 i want to echo $ss. but its echo out "no POST". i am not sure how can i echo the value of qty.

0
$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      return false;
}); 

Is this preventing form submission? If so, you won't get a $_POST['qty'] as the page is not refreshing and you don't have any ajax to provide a post method. So, why not forget the post and take the value directly from the form via js:

$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      $( "#d1Container").html($("#qty").val());
      return false;
}); 

BUT have this:

<input type='text' id='qty' name='qty' />

And this:

<div id='dialog01' title='ccc'> ";
    <div id='d1Container'>No Value</div>
</div>";

Not sure if that'll work once the dialog is open, perhaps you'll need to swap to:

      $( "#d1Container").html($("#qty").val());
      $( "#dialog01" ).dialog( "open" );

Edited by diafol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.