...

View Full Version : Remember values from <?php echo $PHP_SELF;?>



JakeThomas
01-07-2010, 12:13 AM
Ok, so my form is a price calculator ...

<html>
<form method="post" action="<?php echo $PHP_SELF;?>">
<div class="standardinput">
<label>Stock:</label>
<select class="dropdown" name="stock" id="stock">
<option value="Please Select">Please Select</option>
<option value="100gsm Bond">100gsm Bond</option>
<option value="104gsm Expression">104gsm Expression</option>
<option value="120gsm Knight">120gsm Knight</option>
<option value="115gsm Envirocare">115gsm Envircare</option>
</select>
</div>

<div class="standardinput">
<label>Quantity:</label>
<select class="dropdown" name="qty" id="qty">
<option value="Please Select">Please Select</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="250">250</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="2000">2000</option>
<option value="2500">2500</option>
<option value="3000">3000</option>
<option value="4000">4000</option>
<option value="5000">5000</option>
<option value="6000">6000</option>
<option value="7000">7000</option>
<option value="8000">8000</option>
<option value="9000">9000</option>
<option value="10000">10000</option>
<option value="Custom">Custom</option>
</select>
</div>
<input name="Submit" type="submit" class="pricebutton" value="Instant Quote" />
</form>
</html>

<php>
<?php
$qty = $_POST["qty"];
$stock = $_POST["stock"];
?>
</php>


How do I make it so the values created once the "submit" button is pushed, is remember by the drop down form?

abduraooft
01-07-2010, 07:39 AM
How do I make it so the values created once the "submit" button is pushed, is remember by the drop down form?Take a look at http://www.codingforums.com/showthread.php?t=185065

PS: You shouldn't depend upon the ON status of register_globals. See http://php.net/manual/en/security.globals.php and http://www.php.net/manual/en/faq.using.php#faq.register-globals

And your form is susceptible to XSS attacks, see http://seancoates.com/xss-woes

JakeThomas
01-07-2010, 09:12 AM
Thanks!

I've read the post and It works ...

I have no idea how you are able to search for these things, I looked on google for about 45 minutes but came up blank.

I guess if you know what your searching for.

On another note, I have taken your advice and am going to work on another version of the script thats less vulnerable to attacks.

Thankyou for the heads up =)

abduraooft
01-07-2010, 09:56 AM
I've read the post and It works ...

I have no idea how you are able to search for these things, I looked on google for about 45 minutes but came up blank.

I guess if you know what your searching for. Um.. your confusion is visible from your thread title itself :). You'd have looked for "php+retain values in select/drop down form submit (http://www.google.com/search?q=php%2Bretain+values+in+select%2Fdrop+down+form+submit)"

JAY6390
01-07-2010, 01:03 PM
Also, you shouldn't use PHP_SELF. Its not needed. Simply use action="" and it will send to itself anyway. This is to stop XSS attacks also



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum