...

View Full Version : Need help with script



DarkLegacy
10-25-2003, 11:18 PM
<?php

$username = $usercook;
$password = $passcook;
setcookie("usercook", $username);
setcookie("passcook", $password);

require("functions.php");
global $fontString, $tableColor;

if(authenticate($username, $password, 0)) {

$result = @mysql_query("SELECT * FROM members WHERE username = \"$username\"");
$row = mysql_fetch_array($result);
extract($row);

echo("
<form action=changeInfo.php method=post>
<table width=400 border=0 cellspacing=0 cellpadding=0>
<tr><td colspan=2>
$fontString
<center><B><font size=4>Modify User Information</font></B><br><br></center>
</td></tr>
<tr><td width=30% bgcolor=$tableColor>
$fontString
<b>Email:</b>
</td><td width=70% bgcolor=$tableColor>
<input type=text size=30 name=email value=$email>
</td></tr>
<tr><td width=30% bgcolor=$tableColor>
$fontString
<b>Aim: (no spaces)</b>
</td><td width=70% bgcolor=$tableColor>
<input type=text size=30 name=aim value=$aim>
</td></tr>
</td></tr>
<tr><td width=30% bgcolor=$tableColor>
$fontString
<b>Games Played:</b>
</td><td width=70% bgcolor=$tableColor>
<input type=checkbox name=SC value=1");

if($SC == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=http://overdosed.net/images/gamesplayed/sc.gif ALT=\"Starcraft\">
<input type=checkbox name=BW value=1");

if($BW == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=http://overdosed.net/images/gamesplayed/bw.gif ALT=\"Brood War\"><br>
<input type=checkbox name=D2 value=1");

if($D2 == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=http://overdosed.net/images/gamesplayed/d2.gif ALT=\"Diablo II\">
<input type=checkbox name=D2X value=1");

if($D2X == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=http://overdosed.net/images/gamesplayed/d2x.gif ALT=\"Diablo II:LOD\"><br>
<input type=checkbox name=W2 value=1");

if($W2 == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=http://overdosed.net/images/gamesplayed/w2.gif ALT=\"Warcraft II\">
<input type=checkbox name=W3 value=1");

if($W3 == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=http://overdosed.net/images/gamesplayed/w3.gif ALT=\"Warcraft III\"><br>
<input type=checkbox name=HALO value=1");

if($HALO == 1) {
echo(" CHECKED>");}
else {
echo(">");}

echo("<img src=images/gamesplayed/halo.JPG ALT=\"HALO\"><br>
</td></tr>
</td></tr>
<tr><td width=30% bgcolor=$tableColor>
$fontString
<b>Quote:</b>
</td><td bgcolor=$tableColor>
<textarea cols=30 rows=8 name=quote>$quote</textarea>
</td></tr><br>
<tr><td bgcolor=$tableColor colspan=2>
<br><center><input type=submit value=\"Modify User Information\">
</form>
</td></tr>
<tr><td bgcolor=$tableColor colspan=2>
<center><font size=2 face=verdana><b><a href=main.php>Return to main menu</font></b></center>
</td></tr>
</table>
");
}

include("footer.php");

?>







I want it so when someone presses Modify User Information It checks the HALO, BW, ECT boxes and edits the database acordinally.

DarkLegacy
10-25-2003, 11:22 PM
like...
on 'Submit' check box 'SC'
If '1' (Filled) Change value in '$SC' to '1'
If '0' (Unfilled) Change value in '$SC' to '0'

Donno how to put that in PHP terms though.

nicklim
10-30-2003, 09:12 AM
hmm.. on changeinfo.php
you can try this

(it's long and not efficient.. but it works and i don't care about that)

$sc=((isset($_POST['sc']) && $_POST['sc]="1")? 1 : 0 )
....
(same for all the other check boxes)

mysql_query("UPDATE members SET SC='$sc', BW='$bw' ........)

mine had 10 checkbox fields but i stored the checked data as a 10 digit binary value (stored in the database as a integer..) not too sure wheter this is the best way to do it..

(i extracted the coded value using a while($i>0) { $a[]=$i%2; $i=(int) $i / 2 }



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum