|
Posted by Gordon Burditt on 10/24/05 20:21
>I am trying to run a few INSERT queries only if the user clicks 'continue'
>in a <a href> The queries takes variables created from SELECT queries. I
>have tried to acheive this by putting The INSERT queries into a function at
>the top of my php file and having the SELECT queries below it. I have a
>message that pops up that includes a link to the function but I cant get
You can't have a link to a PHP function. Code inside a function
will not be executed unless something calls it. You CAN have a SUBMIT
button for a form, which the user can fill in and click on.
>this to work and am not sure of the best approach. Can anyone help?
>My striped down code is below. Im not even sure if you can just use a
>function to contain code that doesnt return a value. Mine just runs some
>INSERT INTO queries
A function does not have to return a value, and in any case, you
could always supply a dummy value to return.
After a user clicks on the SUBMIT button to a form, you look at
what's in $_GET and $_POST to decide whether or not to call the
function, like the name of the submit button or whether the fields
in the form were filled in.
Gordon L. Burditt
>
>*******************************************************************
><?php
>function PurchaseQuestions(){
>
>various INSERT INTO queries here
>
><h1>Confirmation</h1><br>
><p><a href="logout.php"> Logout</a> or return to <a href="Questions.php">
>Questions Database</a></p><br><br><br>
>Congratulations <b><?php echo $_SESSION[username] ?></b>, your order has
>been completed.</p>
>
><?php
>}
>?>
>
>
><?php
>$OrderDate = date('d/m/Y');
>
>Three SELECT queries here which provides variables for the
>PurchaseQuestions() function
> ?>
> <h1>Order Status</h1>
> <p>You have requested <?php echo $QuestSel; ?> questions at a total cost
>of <strong>£<?php echo $QuestSel*.8; ?></strong>
> If you wish to proceed with the transaction click <a href=<?php echo
>PurchaseQuestions() ?>> Continue</a>.<br>
> <?php
>
> }
>
>?>
><?php
>mysql_close($conn);
>?>
>
>
Navigation:
[Reply to this message]
|