Jump to content

unset and refresh


bagnallc

Recommended Posts

Hi,

I want to include an option on my page which when pressed by a user will unset a variable and then refresh the page with variable now unset.

Is there a way of doing this?

I have included an example of code where this would be relevant

//display the users selected country details
if(isset($countryid)) { echo "<font color='red'>"; }
echo "Country - ";
if(isset($countryid)) {
$countryrow = mysql_fetch_row($countryname);
echo $countryrow[0] . "only."; }
else { echo "NOT LIMITED"; }
if(isset($countryid)) { echo "</font>"; }

So in other words when variable $countryid is set, the above produces a country name and is highlighted red, when its not set it states "NOT LIMITED".

I want a button that can be pressed when variable is set that will unset the variable and refresh page to show this has taken effect.

any ideas?


Many thanks
Link to comment
Share on other sites

[code]<form name="test" id="test" action="samepage" method="post">
<input name="whatever" id="whatever" type="submit" value="change" />
</form>[/code]
WHen they click that change button
on the same page, it will refresh the page, have it run the following code or example.

[code]<?php
if (isset($_POST['whatever'])) {
unset($variablename);
}
?>[/code]
Just modify it to meet your needs.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.