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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Show different if field in MySQL table is something

    Ok, so I need help programming my CPanel.
    My users log in by writing their username and password wich they registered with earlier.

    The database is via MySQL, as you may understand.

    I already have the CPanel up, but I want an other feature to exist.
    A premium rank wich adds special fields in the CPanel IF the user got "premium" to "ok" in their table-row based on username.

    So if they got "ok" on "premium", more options should appear in the CPanel.

    The current CPanel looks like this:


    cpanel.php
    Code:
    				<form action="checklogin.php" method="post">
    				<td>
    				<p align="right">Server Name:</td>
    				
    				<td><input type="text" name="name" value="" size="20"></td>
    			</tr>
    			<tr>
    				<td>
    				<p align="right">Password:</td>
    				<td><input type="password" name="password" size="20"></td>
    			</tr>
    		</table>
    		    </ul>
    
    			<p><input type="submit" value="Login &raquo;" name="Submit"></p>
    </form>
    Checklogin.php
    PHP Code:
    <?php

    $host
    ="***";
    $username="**";
    $dbpassword="**";
    $db_name="**";
    $tbl_name="webclientcreate";

     
    mysql_connect("$host""$username""$dbpassword")or die("cannot connect"); 
     
    mysql_select_db("$db_name")or die("cannot select DB");

     
    $myusername=$_POST['name']; 
     
    $mypassword=$_POST['password']; 

     
    $myusername stripslashes($myusername);
     
    $mypassword stripslashes($mypassword);
     
    $myusername mysql_real_escape_string($myusername);
     
    $mypassword mysql_real_escape_string($mypassword);
     
    $sql="SELECT * FROM webclientcreate WHERE name='$myusername' AND password='$mypassword' AND status='ok'";
     
    $result=mysql_query($sql);

     
    $count=mysql_num_rows($result);

    if(
    $count==1){
     
    session_start(); 
     
    $_SESSION['username'] = ("$myusername");
     
    $_SESSION['password'] = ("$mypassword");
     
    $_SESSION['name'] = $_POST['name'];
     
    header'location: cpanel_edit.php' );
     }
     else {
     echo 
    ''
     
    ?>
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Wrong username/password.</title>
    </head>
    <body>
    <p>Wrong username or password.</p>
    </body>
    </html>
    cpanel_edit.php
    PHP Code:
    <?php

    $host
    ="***";
    $username="***";
    $dbpassword="**";
    $db_name="***";
    $tbl_name="webclientcreate";

     
    mysql_connect("$host""$username""$dbpassword")or die("cannot connect"); 
     
    mysql_select_db("$db_name")or die("cannot select DB");
     
      
    session_start();
      
    $name $_POST['name'];
      
    $ip $_POST['ip'];
      
    $port $_POST['port'];
      
    $loader $_POST ['loader'];
      
    $email $_POST ['email'];
      
    $password $_POST ['password'];  
      
    $background $_POST ['background'];
      
    $download $_POST ['download'];
      
      
    $sql="SELECT * FROM webclientcreate WHERE name='".mysql_real_escape_string($_SESSION['name'])."'";
      if ((
    $result mysql_query($sql))) {
      
        while (
    $row mysql_fetch_array($result)) {
      
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Edit</title>
    </head>
    <body>
                    <form action="cpanel_update.php" method="post" class="uniForm">
                    <td>
                    <p align="right">Server Name:</td>
                    
                    <td><?php echo $row['name'];?></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">IP&Port:</td>
                    <td><input type="text" name="ip" size="20" class="textInput required" value="<?php echo $row['ip'];?>">:<select name="port">
     <option value="43594">43594</option>
     <option value="5555">5555</option>
        </select></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">Email:</td>
                    <td><input type="text" name="email" size="20" maxlength="50" id="email" class="textInput required validateEmail"></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">Email Again:</td>
                    <td><input type="text" name="email_confirm" size="20" maxlength="50" id="email_again" class="textInput required validateSameAs email"></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">Loader:</td>
                    <td><select name="loader">
                <option value="**">InsidiaX</option> 
                <option value="***">HybridPVP v3</option>
              </select></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">Webclient BG:</td>
                    <td><input name="background" data-default-value="http://" size="20" maxlength="65" type="text" value="<?php echo $row['background'];?>" class=""/></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">Desktop Client:</td>
                    <td><input name="download" data-default-value="http://" size="20" maxlength="50" value="<?php echo $row['download'];?>" type="text" class=""/></td>
                </tr>
                <tr>
                    <td>
                    <p align="right">Password:</td>
                    <td><input type="password" name="password" size="20" maxlength="40" class="textInput required"></td>
                </tr>
            </table>
                </ul>

                <p><input type="submit" value="Create &raquo;" name="Submit"></p>
    </form>
        </div>
        </center>
    </div>
        <script>
          $(function(){
            $('form.uniForm').uniform({
              prevent_submit : false
            });
          });
        </script>
    </body>
    </html>
    <?php
      
    }
      } else die(
    mysql_error());
      
    ?>
    Side-note: I have no idea if this is in the right section.

    Any help is appreciated.
    Last edited by Lotto320; 01-14-2012 at 01:10 PM.

  • #2
    New Coder
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Bump bump

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Just stick something like this in your form:
    PHP Code:
    <?php
    if($row['premium'] == 'ok')
    {
        
    ?>
                <tr>
                    <td>
                    <p align="right">Extra field:</td>
                    <td><input type="text" name="extra" size="20" maxlength="40" class="textInput required"></td>
                </tr>
         <?php
    }
    ?>
    You don't need that while() loop if you are only retrieving one record. You only need the mysql_fetch_* function:
    PHP Code:
    $row mysql_fetch_array($result);
    // or, if you don't need the numerical indexes:
    $row mysql_fetch_assoc($result); 

  • Users who have thanked Inigoesdr for this post:

    Lotto320 (01-14-2012)

  • #4
    New Coder
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Works!
    A thousand of thanks to you!


  •  

    Posting Permissions

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