0

i have the folowing code

 <?php
    $datumeind = date("Y-m-d");// current date

    $datumverleden = strtotime(date("Y-m-d", strtotime($datumeind)) . " -99 year");//current date -99 years

    $datumbegin = date('Y-m-d', $datumverleden);

    if(isset($_POST['zenden']))
        {

        if($geboorte_datum <= $datumbegin && $inleven_dood == 'In leven' ){
            ?>
    <script type="text/javascript">
    <!--
    var r=confirm("Klik ok als In Leven."); 
    if (r==true)
    ("<?php $inleven_dood = 'In leven'; ?> ")
    else

    ("<?php $inleven_dood = 'Overleden';     }?> ")
    // -->
    </script>

    <?php

            $updatequery = "UPDATE stamboom_dohmen SET inleven_dood='$inleven_dood' WHERE id='$idpersoon'";
            mysql_query($updatequery) or die (mysql_error()); 
            }

    <form action="gegevens_persoon_bewerken.php" method="post" name="myform" enctype="multipart/form-data">

    <div><input type='checkbox' name='overleden' id='overleden' value='Overleden' title='Kies als overleden.'></div>
    <input type="submit" style=" width:100px;"  name="zenden" value="Alles verzenden"/>
    </form>
    ?>

The code

("<?php $inleven_dood = 'In leven'; ?> ")
        else

        ("<?php $inleven_dood = 'Overleden';     }?> ")

between the javascript dosn't work and i don't know wy
The allert box appears
can someone help me to fix it.
Thanks in advice John
Thanks in advice

Edited by johnnyd1963

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Citytech.tester
0

It doesn't work because JavaScript is executed on the client side, and PHP is executed on the server side.

You could try using a normal form to post the confirmation back to the server, of if you want it to function asynchronously, you could use AJAX.

If using AJAX, I'd recommend you consider using a JavaScript framework, e.g. jQuery, to handle the heavy lifting.

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.