Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-10-2005, 04:21 PM Submit Button
Junior Talker

Posts: 4
Trades: 0
I want to have this submit button submit all the changes I make in this code, but I dont know where to place the <form> or how to place it so it will refresh the page with the saved information...

Code:
 <? // place at top of page.. before include stuff.
 ob_start(); // Start output buffering.
 session_start(); // Start the session.
 ?>
 
 <html>
 <head>
 <title>Alone & Broken - Welcome</title>
 <link rel="stylesheet" type="text/css" href="http://www.aloneandbroken.com/setup.css">
 </head>
 <body bgcolor="501010">
 <table height="100%" width="100%" cellspacing="0" cellpadding="0" border="0">
 <tr>
 
 <?
 include('http://www.aloneandbroken.com/leftnavagation.html');
 ?>
 
 <?
 include('http://www.aloneandbroken.com/headbar.html');
 ?>
 <? // admin.php
 if (($_SESSION['admin']) != 1) {
 echo 'You dont have permission to access this part of the website.';
 } else {
 if (isset($_POST['submit'])) {
 
 if ($_POST['banned'] == '0') {
 mysql_query("UPDATE usertable SET ban = 1 WHERE username = '" . $_POST['username'] . "'");
 }
 
 echo 'Please make sure you ban the right user, and do not ban any admins! If you ban an admin or a user for no reason then I will remove your status as an admin. When leaving a reason, please type the message out like this "For hacking." or "You cheated in a game." etc. Don\'t use "s, only type in your message, and when the user sees it, it will show up as "Reason: You cheated in a game.". Thanks.
 <p>';
 
 mysql_connect("localhost", "*****", "*****") or
    die("Could not connect: " . mysql_error());
 mysql_select_db("instagib_hopeful");
 
 $get_users = mysql_query("SELECT * FROM usertable ORDER BY username ASC");
 
 do {
 $status = $a['ban'];
 if ($status == 0) {
 # They're unbanned
 $status = 'Unbanned';
 $val = '';
 } else {
 $status = 'Banned';
 $val = $a['reason'];
 }
 
 
 echo '
 <table width="400" cellspacing="4" cellpading="0" border="0" align="center">
 <td width="400" bgcolor="301010" align="center">
 <p><font style="font-size: 9px"><b>[' . $a['username'] . ']</b> <i>(' . $status . ')</i><div align="center">Ban:<input type="checkbox" name="banned">&nbsp;Reason For Ban: <input style="color: 000000" type="text" name="reason" value="' . $val . '"><br /></font></div>
 </td>
 </table>
 ';
 
 } while ($a = mysql_fetch_array($get_users));
 echo '<p><center>
 <input style="color: 000000" type="submit" value="Submit" name="submit">
 </center><p>';
 }
 }
 ?>
 
 </td>
 </tr>
 </table>
 </td>
 
 <?
 include('http://www.aloneandbroken.com/rightnavagation.html');
 ?>
 
 <? // place at end of page.. (after other include junk)
 ob_end_flush(); // Send everything to the Web browser.
 ?>
 
 </tr>
 </table>
 </body>
 </html>
Actually I don't know if I even need form. What the page does is when I try to visit it, none of the displayed information (Username, ban status, etc.) shows up... (Sorry if I'm not making sense, just ask and i'll clarify)

Last edited by 0beron; 07-10-2005 at 07:41 PM.. Reason: Scrubbed Database login info
verdammung is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-10-2005, 05:45 PM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Umm, it might be easier if the submit button was in the same table as everything else.
I don't think it has got to be, but I find it just tidies things up.

Try this, it should be alright.



PHP Code:
<? // place at top of page.. before include stuff.
ob_start(); // Start output buffering.
session_start(); // Start the session.
?>

<html>
<head>
<title>Alone & Broken - Welcome</title>
<link rel="stylesheet" type="text/css" href="http://www.aloneandbroken.com/setup.css">
</head>
<body bgcolor="501010">
<table height="100%" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
</td>

<?
include('http://www.aloneandbroken.com/leftnavagation.html');
?>

<?
include('http://www.aloneandbroken.com/headbar.html');
?>
<? 
// admin.php
if (($_SESSION['admin']) != 1) {
echo 
'You dont have permission to access this part of the website.';
} else {
if (isset(
$_POST['submit'])) {

if (
$_POST['banned'] == '0') {
mysql_query("UPDATE usertable SET ban = 1 WHERE username = '" $_POST['username'] . "'");
}

echo 
'Please make sure you ban the right user, and do not ban any admins! If you ban an admin or a user for no reason then I will remove your status as an admin. When leaving a reason, please type the message out like this "For hacking." or "You cheated in a game." etc. Don\'t use "s, only type in your message, and when the user sees it, it will show up as "Reason: You cheated in a game.". Thanks.
<p>'
;

mysql_connect("localhost""instagib_hope""skyhind907") or
   die(
"Could not connect: " mysql_error());
mysql_select_db("instagib_hopeful");

$get_users mysql_query("SELECT * FROM usertable ORDER BY username ASC");

do {
$status $a['ban'];
if (
$status == 0) {
# They're unbanned
$status 'Unbanned';
$val '';
} else {
$status 'Banned';
$val $a['reason'];
}


echo 
'
<table width="400" cellspacing="4" cellpading="0" border="0" align="center">
    <tr><form name="form1" method="post" action="">
      <td width="400" bgcolor="301010" align="center"><p><font style="font-size: 9px"><b>[' 
$a['username'] . ']</b> <i>(' $status ')</i><div align="center">Ban:<input type="checkbox" name="banned">&nbsp;Reason For Ban: <input style="color: 000000" type="text" name="reason" value="' $val '"><br /></font></div></td>
    
'
;

} while (
$a mysql_fetch_array($get_users));
echo 
'<p><center>
<input style="color: 000000" type="submit" value="Submit" name="submit">
</center><p>

</form>
    </tr>
          </table>'
;
}
}
?>


<?
include('http://www.aloneandbroken.com/rightnavagation.html');
?>

<? // place at end of page.. (after other include junk)
ob_end_flush(); // Send everything to the Web browser.
?>

</tr>
</table>
</body>
</html>
And change the form details * <form name="form1" method="post" action=""> *

I haven't tested it so could be something wrong somewhere.
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 07-10-2005 at 05:48 PM..
lothop is offline
Reply With Quote
View Public Profile
 
Old 07-10-2005, 06:12 PM
Junior Talker

Posts: 4
Trades: 0
that didn't seem to do anything except ad a giant blank space above the rest of the code... so that didnt work.
verdammung is offline
Reply With Quote
View Public Profile
 
Old 07-10-2005, 09:27 PM
Junior Talker

Posts: 4
Trades: 0
It shows everything unless I put in the

PHP Code:
 if (isset($_POST['submit'])) { 
command, then everything between that goes invisible... please, anyone have any ideas??
verdammung is offline
Reply With Quote
View Public Profile
 
Old 07-10-2005, 11:29 PM
Jacky's Avatar
Novice Talker

Posts: 14
Trades: 0
What actually your codes trying to do? The <form> tag can be placed after <table> and before <tr>. The </form> tag can be placed after the last </tr> and before </table>. This should get rid of the blank space.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Jacky is offline
Reply With Quote
View Public Profile Visit Jacky's homepage!
 
Old 07-11-2005, 10:57 AM
Junior Talker

Posts: 4
Trades: 0
My code makes a list of all the members that are in a table, which works fine, and has a checkbox and an input box, and a status of (banned) or (unbanned). When the checkbox is checked it should ban/unban the user (depending of their status) and the input box is the reason which I have under another row in my table. Anyway it gets all the information fine, its just when I try to make it into a submitable table that it decides to quit working...



No matter what I do it keeps quitting on me!! >.<;;

Last edited by verdammung; 07-11-2005 at 11:08 AM..
verdammung is offline
Reply With Quote
View Public Profile
 
Old 07-13-2005, 12:54 AM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
You could write a function so when the the (unban) link is hit, it takes the browser to memberschange.php?person=Gary&a=unban

Then get it to change the person to be unbanned, then send the browser back to the members.php. (or what ever you list ur users in)

Thats how I do mine.

So, your pulling all your information off your database to display their information. and make it so the unban link is in this form.

<a href="memberschange.php?person=$name&a=unban">Unba n</a>

Replace $name with what ever you print out their name with.

Then on memberschange.php, have it pull the information name and action down and then proceed in changing the persons status, WHERE name = $person (or what ever)

If you still have problems let me know and I'll give some code examples.
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Submit Button
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.35932 seconds with 12 queries