Register for your free account! | Forgot your password?

You last visited: Today at 08:09

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help] with PHP Code

Discussion on [Help] with PHP Code within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2007
Posts: 87
Received Thanks: 0
[Help] with PHP Code

Hi there, how do I link these two PHP codes together?

Code:
<?php
$conn = mysql_connect("localhost", "root", "jhdyjkkaj");
$db = mysql_select_db("cq");

if(isset($_POST['submit']))
{
     if(isset($_POST['pass']) && $_POST['pass'] != "")
     {
          if($_POST['pass'] == $_POST['pass2'])
          {
               if(strlen($_POST['pass']) > 3 && strlen($_POST['pass']) < 32)
               {
                    $sql = "INSERT INTO `accounts` (Username, Password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
                    $sql = mysql_query($sql);
                    echo "Registered Successfully, use your browser to go back.";
               } else {
                    die("Your password must be between 3 and 32 characters.");
               }
          } else {
               die("Your passwords do not match.");
          }
     } else {
          die("Please enter in a password.");
     }
}
?>

and


Code:
$username = $_POST["user"];

$query = mysql_query("SELECT * FROM accounts WHERE Username='$username'");

if(mysql_num_rows($query) != 0)
{
echo "Username already exists";
}
else
{

}
kyle191 is offline  
Old 12/30/2011, 02:03   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Not really a private server question. Google it
I don't have a username is offline  
Old 12/30/2011, 13:57   #3
 
Mr_PoP's Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
PHP Code:
<?php
$conn 
mysql_connect("localhost""root""jhdyjkkaj");
$db mysql_select_db("cq");
$username $_POST["user"];


if(isset(
$_POST['submit']))
{
    if(isset(
$_POST['user'])){
        
$query mysql_query("SELECT * FROM accounts WHERE Username='$username'");

        if(
mysql_num_rows($query) != 0){
            echo 
"Username already exists";
        }
        else{
            if(isset(
$_POST['pass']) && $_POST['pass'] != "")
             {
                  if(
$_POST['pass'] == $_POST['pass2'])
                  {
                       if(
strlen($_POST['pass']) > && strlen($_POST['pass']) < 32)
                       {
                            
$sql "INSERT INTO `accounts` (Username, Password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
                            
$sql mysql_query($sql);
                            echo 
"Registered Successfully, use your browser to go back.";
                       } else {
                            die(
"Your password must be between 3 and 32 characters.");
                       }
                  } else {
                       die(
"Your passwords do not match.");
                  }
             } else {
                  die(
"Please enter in a password.");
             }
        }
    }
    else{
        die(
"Please enter ther user name.");
    }
}
?>
Mr_PoP is offline  
Old 12/30/2011, 17:11   #4
 
elite*gold: 0
Join Date: Nov 2007
Posts: 87
Received Thanks: 0
Quote:
Originally Posted by Mr_PoP View Post
PHP Code:
<?php
$conn 
mysql_connect("localhost""root""jhdyjkkaj");
$db mysql_select_db("cq");
$username $_POST["user"];


if(isset(
$_POST['submit']))
{
    if(isset(
$_POST['user'])){
        
$query mysql_query("SELECT * FROM accounts WHERE Username='$username'");

        if(
mysql_num_rows($query) != 0){
            echo 
"Username already exists";
        }
        else{
            if(isset(
$_POST['pass']) && $_POST['pass'] != "")
             {
                  if(
$_POST['pass'] == $_POST['pass2'])
                  {
                       if(
strlen($_POST['pass']) > && strlen($_POST['pass']) < 32)
                       {
                            
$sql "INSERT INTO `accounts` (Username, Password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
                            
$sql mysql_query($sql);
                            echo 
"Registered Successfully, use your browser to go back.";
                       } else {
                            die(
"Your password must be between 3 and 32 characters.");
                       }
                  } else {
                       die(
"Your passwords do not match.");
                  }
             } else {
                  die(
"Please enter in a password.");
             }
        }
    }
    else{
        die(
"Please enter ther user name.");
    }
}
?>

I get an error on line 4 with this code.
kyle191 is offline  
Old 12/30/2011, 21:13   #5
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
Change $username = $_POST["user"] to $username = $_POST["username"]
_tao4229_ is offline  
Old 12/30/2011, 22:04   #6
 
elite*gold: 0
Join Date: Nov 2007
Posts: 87
Received Thanks: 0
Code:
<?php
$conn = mysql_connect("localhost", "root", "djhbsnu73h");
$db = mysql_select_db("cq");
$username = $_POST["username"];


if(isset($_POST['submit']))
{
    if(isset($_POST['user'])){
        $query = mysql_query("SELECT * FROM accounts WHERE Username='$username'");

        if(mysql_num_rows($query) != 0){
            echo "Username already exists";
        }
        else{
            if(isset($_POST['pass']) && $_POST['pass'] != "")
             {
                  if($_POST['pass'] == $_POST['pass2'])
                  {
                       if(strlen($_POST['pass']) > 3 && strlen($_POST['pass']) < 32)
                       {
                            $sql = "INSERT INTO `accounts` (Username, Password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
                            $sql = mysql_query($sql);
                            echo "Registered Successfully, use your browser to go back.";
                       } else {
                            die("Your password must be between 3 and 32 characters.");
                       }
                  } else {
                       die("Your passwords do not match.");
                  }
             } else {
                  die("Please enter in a password.");
             }
        }
    }
    else{
        die("Please enter ther user name.");
    }
}
?>
I get no errors which display now, but it says "Please enter ther user name." I inputted a username that already exists in the database and also one that doesn't exist. I get the same message and no MYSQL insert.

PS, my Database config is correct.
kyle191 is offline  
Old 12/30/2011, 22:24   #7
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Learn to code PHP.
I don't have a username is offline  
Old 12/30/2011, 22:36   #8
 
elite*gold: 0
Join Date: Nov 2007
Posts: 87
Received Thanks: 0
Why?? When I have all this help lol.
kyle191 is offline  
Old 12/30/2011, 22:47   #9
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by kyle191 View Post
Why?? When I have all this help lol.
Because then you learn to do something and won't have to ask for help all the time. You ain't asking your mom to do your stuff all the time for you either, are you?
I don't have a username is offline  
Thanks
1 User
Old 12/30/2011, 23:56   #10
 
elite*gold: 0
Join Date: Nov 2007
Posts: 87
Received Thanks: 0
I bet you don't even know how to fix the code do ya? lol
kyle191 is offline  
Old 12/31/2011, 00:06   #11
 
Lateralus's Avatar
 
elite*gold: 0
Join Date: May 2005
Posts: 1,892
Received Thanks: 920
Quote:
Originally Posted by kyle191 View Post
I bet you don't even know how to fix the code do ya? lol
I bet you don't.
Lateralus is offline  
Old 12/31/2011, 00:14   #12
 
elite*gold: 0
Join Date: Nov 2007
Posts: 87
Received Thanks: 0
Quote:
Originally Posted by Lateralus View Post
I bet you don't.
I don't, clearly from what I've been asking for the last few hours.
I really can't see what's wrong with it tbh. My guess it's XAMPP.
kyle191 is offline  
Old 12/31/2011, 02:52   #13
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by kyle191 View Post
I bet you don't even know how to fix the code do ya? lol
I'm not coding PHP, but I can easy fix it. With your attitude give me 3 reason why I should fix it.
I don't have a username is offline  
Old 12/31/2011, 08:17   #14
 
BioHazarxPaul's Avatar
 
elite*gold: 0
Join Date: Nov 2005
Posts: 548
Received Thanks: 93
There is a better way to code register pages..
BioHazarxPaul is offline  
Old 12/31/2011, 09:12   #15
 
elite*gold: 0
Join Date: Feb 2007
Posts: 240
Received Thanks: 22
bunch of examples out there,
agathom is offline  
Reply


Similar Threads Similar Threads
[Biete]1x Allstar Akali Code 2x Riot Nasus Code 7x PAX JAX Code
09/26/2011 - League of Legends Trading - 7 Replies
Hi, ich habe die Codes gewonnen und möchte sie nun verkaufen da ich kein LoL mehr Spiele. Skype: nashvil. mit dem Punkt! Ich erhalte die Paysafecards zuerst! Egal wieviele TBM ihr habt!
Biete AW50F Code + Javelin Code + Kamazaki Code an
08/18/2011 - WarRock Trading - 6 Replies
Biete AW50F Code + Javelin Code + Kamazaki Code an Was biete Ich _________________________________________________ _ _________________ ----- AW50F CODE ----- Javelin Code
Waffen Code´s - Premium Code´s - Dinar Code´s [VERKAUFBAR] ! ! !
03/10/2011 - WarRock Trading - 3 Replies
Hallo Leute , ich verkaufe Code´s . Die Code´s werde ich jetzt darunter hinschreiben und ihr könnt euch bei mir melden 50 % Günstiger Als WarRock Marketplace . 1.Waffen Code´s >>> G36 Code Xm8 Code Javelin Code Mp7a1 Code Famas Retail Code G36 Retail Code



All times are GMT +1. The time now is 08:09.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.