Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help Changing Database Values on Submit Button, With PHP

    <?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.
    Last edited by DarkLegacy; 10-26-2003 at 03:53 AM.

  • #2
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by DarkLegacy; 10-26-2003 at 12:25 AM.

  • #3
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •