/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] unset()

Can I use unset on a button?
What my button does, is uploads images, but if the user uploads an image, It uploads the image and shows the form, plus the previously uploaded images, and if they press refresh instantly after the image uploads, it uploads the image again.

[code=html]<button type=”submit” name=”upload_images”>Upload</button>[/code]

[code=php]if(isset($_POST[‘upload_images’])){
foreach ($_FILES[“pictures”][“error”] as $key => $error){
if($error === 0){
$filename = time().$_FILES[“pictures”][“name”][$key];
move_uploaded_file($_FILES[“pictures”][“tmp_name”][$key], “images/userimages/$filename”);
createThumbnail(“images/userimages”, “$filename”, “images/userimages/thumbs”, 100);
mysql_query(“INSERT INTO pictures(`id`, `filename`) VALUES (‘$_SESSION[userid]’, ‘$filename’)”)or die(mysql_error());
}
}
echo'<p>Upload Successful</p>’;
unset($_POST[‘upload_images’]);[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bokehOct 21.2006 — The reason this is happening is because you are not using a landing page.
Copy linkTweet thisAlerts:
@The_Little_GuyauthorOct 21.2006 — What's a "landing page"? Never heard of it before.
Copy linkTweet thisAlerts:
@bokehOct 21.2006 — After a POST request, if the POST request was deamed successful the client should forwarded to a different url using a GET request. i.e. the script that processes the POST request should send no output whatsoever only a header redirect to the URL that creates the success page. The POST request processing script and the landing page could be combined in the same script.
Copy linkTweet thisAlerts:
@The_Little_GuyauthorOct 21.2006 — Cool. It works thanks.
×

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...