Results 1 to 4 of 4

Thread: My data does not fit in my database

  1. #1
    Join Date
    Jun 2009
    Posts
    83

    My data does not fit in my database

    Here, I present my code that is almost functional. Errors are displayed properly and when registration is OK, the mail is sent. The worry is that it tells me that the member is not on the table so the script was a failure somewhere.

    PHP Code:
    <?php include("../includes/head1.php" ); ?> 
    <body> 
    <!-- wrap starts here --> 
    <div id="wrap">  
     <?php include("../includes/menu2.php" ); ?>   
     <!-- content-wrap starts here --> 
     <div id="content-wrap"> 
      <div id="main">     
          <?php //text start 
       
    ?>
      <?php 
    if(isset($_SESSION['log']['pseudo']) AND !empty($_SESSION['log']['pseudo'])){ 
    ?><p class="error2">You are already subscribed to Enigmatic</p> 
     <?php 

    else 

    ?><?php 
    /* Verify that entries are allowed */ 
    if(STATUSINSC == 1){ 
     if(isset(
    $_POST['email']) AND isset($_POST['pseudo']) AND isset($_POST['password']) AND isset($_POST['password2']) AND isset($_POST['pseudo'])){ 
      
    /* Verify that the variables are not empty */ 
      
    if(!empty($_POST['email']) AND !empty($_POST['pseudo']) AND !empty($_POST['password']) AND !empty($_POST['password2'])){ 
       
    /* Verify that the email is valid */ 
       
    if(isMail($_POST['email'])){ 
        
    $sql 'SELECT id, email, pseudo, password FROM _users WHERE pseudo="'$_POST['pseudo'] .'"'
        
    $req $connection->query($sql); 
        
    $req->setFetchMode(PDO::FETCH_OBJ); 
        
    $res $req->rowCount(); 
        
    $requests++; /* Add 1 to variable requests */ 
        /* Checks if the username is already used */ 
        
    if(($res) == 0){ 
         
    /* Verifies that the password contains at least 8 characters */ 
         
    if(strlen($_POST['password']) >= NBCARSMIN){ 
          
          
    /* Checks if the two passwords are the same */ 
          
    if($_POST['password'] == $_POST['password2']){ 
           
           
    /* Verify that the username contains at least 2 characters */ 
           
    if(strlen($_POST['pseudo']) >= NBCARSMINP){ 
            
            
    /* Verify that the username is valid (no special characters except - and _) */ 
            
    if(preg_match("#^[a-zA-Z0-9-_]+$#"$_POST['pseudo'])){ 
             
             
    /* Everything is good, adding to the database */ 
              
             /* Declaration and Treatment */ 
             
    $email mysql_real_escape_string(htmlentities(addslashes($_POST['email']))); 
             
    $pseudo mysql_real_escape_string(htmlentities(addslashes($_POST['pseudo']))); 
             
    $password mysql_real_escape_string(sha1($_POST['password'])); 
             
    /* dateinscription = NOW() */ 
             
    $prename mysql_real_escape_string(ucfirst($_POST['prename'])); 
             
    $name mysql_real_escape_string(ucfirst($_POST['name'])); 
             
    $datebirth ''.$_POST['years_birth'].'-'.$_POST['months_birth'].'-'.$_POST['day_birth'].''
             
    $pays mysql_real_escape_string(ucfirst($_POST['pays'])); 
             
    $city mysql_real_escape_string(ucfirst($_POST['city'])); 
             
    $typeofmember 'Member'// Default type 
             
    $points 0
             
    /* Account Activated = 0 */ 
             
    $codeactivation randomString(18); 
             
    $sql 'INSERT INTO _users VALUES("", "'$email .'", "'$pseudo .'", "'$password .'", NOW(), "'$prename .'", "'$name .'", "'$datebirth .'", "'$pays .'", "'$city .'", "'$typeofmember .'", "'$codeactivation .'", "'$points .'" )'
             
    $connection->exec($sql); 
             
    $requests++; 
              
             
    $contentmessage 
             Hello, 
              
             you just register on Enigmatic, but your account is currently not active.
              For activatation, you must click on this link if the link does not work, try copy / paste in the bar address in your browser.
              In case of problem of activation, please contact the administrator.
              
              Your link '
    CHEMINROOT"Activation /? & Nickname = '. $username. '& ac ='. $codeactivation. "
              
              
    Enigmatic soon on, and enjoy your visit
             
    '; 
              
             echo '
    <class="ok">Your registration is well doneYou will receive an email to activate your account</p>'; 
              
             mail($email, "Activating your account", $contentmessage); 

            } 
            else{ 
             
             echo '
    <class="error2">Your username is incorrectit should be composed only of alphanumeric characters or symbols : - _</p>'; 
            } 
           } 
           else{ 
            
            echo '
    <class="error2">Your nickname must consist of at least 2 characters</p>';
           } 
          } 
          else{ 
           
           echo '
    <class="error2">Both passwords are different</p>'; 
           
          } 
          
         } 
         else{ 
          
          echo '
    <class="error2">Your password must be composed of at least 8 characters</p>';
         } 
        } 
        else{ 
         
         echo '
    <class="error2">The pseudo <em>'. $_POST['pseudo'] .'</emis already used by someone else</p>';
        } 
       } 
       else{ 
        
        echo '
    <class="error2">The format of your email is invalid</p>'; 
        
       } 
     
      } 
      else{ 
     
       echo '
    <class="error2">Please fill in all fields</p>';
      } 
     } 

    else{ 
     
     echo '
    <class="error2">Registration is currently closed !</p>';

    ?>
    <form method="post" action=""> 
     
     <p><em>* Required field</em></br></br></br>
      
     <label for="email">Your email * :</label> <input type="text" name="email" id="email" size="28" /><span class="error"></span></br></br>
     <label for="pseudo">Your pseudo * :</label> <input type="text" name="pseudo" id="pseudo" size="28" /><span class="error"></span></br></br>
     <label for="password">Password * : </label> <input type="password" name="password" id="password" size="28" /></br></br>
     <label for="password2">Confirmation * :</label> <input type="password" name="password2" id="password2" size="28" /><span class="error"></span></br></br></br>
      
     <label for="prename">Your prename :</label> <input type="text" name="prename" id="prename" size="28" /></br></br> 
     <label for="name">Your name :</label> <input type="text" name="name" id="nom" size="28" /></br></br> 
      
     <label for="datebirth">Birth:</label> 
     <select name="day_birth"> 
      <option value="01">1</option> 
      <option value="02">2</option> 
      <option value="03">3</option> 
      <option value="04">4</option> 
      <option value="05">5</option> 
      <option value="06">6</option> 
      <option value="07">7</option> 
      <option value="08">8</option> 
      <option value="09">9</option> 
      <option value="10">10</option> 
      <option value="11">11</option> 
      <option value="12">12</option> 
      <option value="13">13</option> 
      <option value="14">14</option> 
      <option value="15">15</option> 
      <option value="16">16</option> 
      <option value="17">17</option> 
      <option value="18">18</option> 
      <option value="19">19</option> 
      <option value="20">20</option> 
      <option value="21">21</option> 
      <option value="22">22</option> 
      <option value="23">23</option> 
      <option value="24">24</option> 
      <option value="25">25</option> 
      <option value="26">26</option> 
      <option value="27">27</option> 
      <option value="28">28</option> 
      <option value="28">29</option> 
      <option value="30">30</option> 
      <option value="31">31</option> 
     </select> 
      
     <select name="month_birth"> 
      <option value="01">January </option> 
      <option value="02">February </option> 
      <option value="03">March </option> 
      <option value="04">April</option> 
      <option value="05">May</option> 
      <option value="06">June</option> 
      <option value="07">July </option> 
      <option value="08">August </option> 
      <option value="09">September </option> 
      <option value="10">October</option> 
      <option value="11">November </option> 
      <option value="12">December </option> 
     </select> 
      
     <select name="years_birth"> 
      <?php 
        
       $date = date("Y" )-101; 
       while($date < date("Y" )){ 
        
        $date++; 
        echo '
    <option value="'. $date .'">'. $date .'</option>'; 
        
       } 
        
      ?> 
     </select> 
     </br></br>
      
     <label for="pays">Pays :</label> <input type="text" name="pays" id="pays" size="28" /></br></br>
     <label for="city">City:</label> <input type="text" name="city" id="city" size="28" /></br></br>
      
     <?php  
      
     if(STATUSINSC == 1){ 
      
     echo '
    <input type="submit" id="submit" value="register" />'; 
      
     } 
      
     ?> 
      
     </p> 
     
    </form> 
     <?php }  
    //text end ?></div> 
       
       <?php  
    include("../includes/sidebar1.php" ); 
    ?> 
       
         
     <!-- content-wrap ends here -->  
     </div> 
          
     <!--footer starts here--> 
    <?php include("../includes/foot.php" ); ?> 
     
    <!-- wrap ends here --> 
    </div> 
     
    </body> 
    </html>

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: My data does not fit in my database

    and Apache logs you have nothing?

    That said, even if the object behind, I find it odd to give "exec" to name a method ...

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: My data does not fit in my database

    1) The strings in a query are delimited by single quotes, not double.
    2) You can see your connection object?

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: My data does not fit in my database

    it would be nice to get code error performance of your sql query. And to begin the name of a table with a _ I wonder if it's a good idea ...

Similar Threads

  1. I am unable to enter the data into database.
    By weblink.ashish in forum Software Development
    Replies: 1
    Last Post: 07-06-2011, 12:42 AM
  2. Representing a data in a database
    By kALAMATHI in forum Software Development
    Replies: 3
    Last Post: 21-01-2011, 07:47 AM
  3. Conversion of excel data into sql database.
    By Nakul2 in forum Windows Software
    Replies: 5
    Last Post: 27-08-2010, 04:35 PM
  4. Storing database data into Map
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 20-02-2010, 01:17 AM
  5. What are the types of DATA in a SQL Database
    By Doroteo in forum Software Development
    Replies: 3
    Last Post: 06-11-2009, 10:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,493,269.33703 seconds with 17 queries