#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0

    Help keep getting error


    I keep getting "Sorry, we couldn't register you at this time." and i can find out why?

    PHP Code:
    <?php
    require'admin_connect.php';
    require
    'core.php';
    if(!
    loggedin()){
    if (isset(
    $_POST['username'])&&isset($_POST['p'])&&isset($_POST['p2'])&&isset($_POST['regpass']) ){
        
    $username $_POST['username'];
        
    $p $_POST['p'];
        
    $p2 $_POST['p2'];    
        
    $password md5($p);
        
    $regpass $_POST['regpass'];
        
        if (!empty(
    $username) && !empty($p) && !empty($p2) && !empty($regpass)){
            if (
    $p!=$p2){
                echo 
    'Passwords do not match.';
                }else{
                    
    $query "SELECT `pass` FROM `ids` WHERE `pass` = '".$regpass."'";
                    
    $query_run mysql_query($query);
                    if (
    mysql_num_rows($query_run)==1){
                    
    $query "SELECT `username` FROM `users` 
                    WHERE `username` = '"
    .$username."'";
                    
    $query_run mysql_query($query);
                    if (
    mysql_num_rows($query_run)==1){
                        echo 
    'The username '.$username.' already exists' ;
                        }else{
                            
    $random 123456789;
                            
    $query "INSERT INTO `users` VALUES ('',
                            '"
    .mysql_real_escape_string($username)."',
                            '"
    .mysql_real_escape_string($password)."')
                            AND INSERT INTO `ids` VALUES ('"
    .$random."') 
                            AND DELETE FROM `ids` WHERE `pass` = '"
    .$regpass."'";
                            if (
    $query_run mysql_query($query)){
                                
    header('Location: index.php');
                                }else{
                                echo 
    'Sorry, we couldn\'t register you at this time.';
                                    }
                            }
                    }
                }
                    
                }else{
                    echo 
    'Invaild registersation key!';
                    }
            }else{ 
                echo 
    'All fields are required.';
                }



    ?>
    Code:
    <html>
    <body>
    <form action="register.php" method="post" >
    Username:<input type="text" name="username"  /><br><br>
    Password:<input type="password" name="p" /><br><br>
    Retype-Password:<input type="password" name="p2" /><br><br>
    Register#:<input type="text" name="regpass" /><br><br>
    <input type="submit" name="submit" />
    </form>
    </body>
    </html>
    PHP Code:
    <?php

    }else if (loggedin())
    echo 
    'You\'re already registered and logged in.';

    ?>
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,143
    Rep Power
    9398
    That INSERT AND INSERT AND DELETE stuff is completely invalid. That's the problem.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0
    Thank you new to this got to read up on it more thanks again!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0
    Any idea on how to make that work?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0
    I know the commented code is what is wrong but, I don't know how to fix it?

    PHP Code:
    <?php 
    require'admin_connect.php'
    require
    'core.php'
    if(!
    loggedin()){ 
    if (isset(
    $_POST['username'])&&isset($_POST['p'])&&isset($_POST['p2'])&&isset($_POST['regpass']) ){ 
        
    $username $_POST['username']; 
        
    $p $_POST['p']; 
        
    $p2 $_POST['p2'];     
        
    $password md5($p); 
        
    $regpass $_POST['regpass']; 
         
        if (!empty(
    $username) && !empty($p) && !empty($p2) && !empty($regpass)){ 
            if (
    $p!=$p2){ 
                echo 
    'Passwords do not match.'
                }else{ 
                
    //   $query = "SELECT `pass` FROM `ids` WHERE `pass` = '".$regpass."'"; 
                  //  $query_run = mysql_query($query); 
                    //if (mysql_num_rows($query_run)==1){
                    
    $query "SELECT `username` FROM `users`  
                    WHERE `username` = '"
    .$username."'"
                    
    $query_run mysql_query($query); 
                    if (
    mysql_num_rows($query_run)==1){ 
                        echo 
    'The username '.$username.' already exists' 
                        }else{ 
                          
    // $random = 123456789; 
                          //  $query = "INSERT INTO `users` VALUES ('', 
                         //   '".mysql_real_escape_string($username)."', 
                          //  '".mysql_real_escape_string($password)."') 
                          //  AND INSERT INTO `ids` VALUES ('".$random."')  
                      //      AND DELETE FROM `ids` WHERE `pass` = '".$regpass."'"; 
                            
    if ($query_run mysql_query($query)){ 
                                
    header('Location: index.php'); 
                                }else{ 
                                echo 
    'Sorry, we couldn\'t register you at this time.'
                                    } 
                            } 
                    } 
                } 
                     
                }else{ 
                    echo 
    'Invaild registersation key!'
                    } 
            }else{  
                echo 
    'All fields are required.'
                } 



    ?>
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Ambala City
    Posts
    1
    Rep Power
    0

    Hi , Can any body help me. I have a Simple html form with these fields : name email


    Hi ,

    Can any body help me. I have a Simple html form with these fields :

    name
    email
    phone
    message

    city
    country

    Number of adults
    children

    days year
    i mean i have to make a simple long form to get informartion about coustomers for hotels. Is it possible to only make a html form and get that all info via php ??? Please help anybody
  12. #7
  13. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,673
    Rep Power
    1958
    Why the INSERT and DELETE? if you only need to get data SELECT will be enough.

IMN logo majestic logo threadwatch logo seochat tools logo