Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it,
follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given
their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!
[HTML/PHP] Pop-ups & forms
Posts
Depends on how you designed your code! :lol:
edit: here's the general form of having a one-shot form/post window,
if (isset($_POST['submit'])) { // do my deleting in the database here // then HTTP redirect to the window close header('Location: closewin.html'); } else { ?> <html> ... <form method="post"> <input name="submit" type="submit" value="Delete"> </form> ... </html> <? }The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
delete.php
<?php header('Location: http://localhost/index.php'); $link = mysql_connect('localhost', 'root', '******'); $db = mysql_select_db('backlog'); $table = sprintf("%s", mysql_real_escape_string($_GET[table])); $id = sprintf("%s", mysql_real_escape_string($_GET[id]));; mysql_query("DELETE FROM $table WHERE id = $id"); mysql_close($link); ?>So if update.php submits to itself and you have code that checks for a form submission, once you've done all the updates you just echo html that will close that window instead of redirecting or going to some other page. Any javascript you echo there should be able to refresh the parent (index.php or whatever opened the popup) and then close itself.
Oh god, why is your table a variable?? :lol:
Also, there sprintf's are totally doing nothing.
$id = intval($_GET['id']); mysql_query("DELETE FROM mytable WHERE id = $id");Also, I recommend putting the redirect as the last line, after processing. As mentioned by another earlier, you should do all your processing, then do your output. In this case, your output is simply the redirect header.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
Table, aka system name. I need to pass it to identify which table is being modified.
I ask because I'm getting the "cannot modify header information" error. Regardless of where I place that line in the file.
You'll want to rethink your database design then.
Make sure you don't have a space or anything before your opening <? in the file.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
ed: Nevermind, figured it out. Set notepad++ UTF-8 encoding to without BOM, which seemed to fix it.