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
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts

    Form Submit 0's in Databaste

    I'm making a referral script where the user registers to the host and then submits his information with the hostsid which is the only thing that shows in the database everything else shows up as 0's



    The Form
    PHP Code:
    <?php 
     
    if( $_REQUEST['task']=='friends'){
          
    if (isset(
    $_GET['y'])) {
        
    $y $_GET['y'];
    } else {
        
    $y 0;
    }

        
    if ((
    strlen($y) == 32)) {

        
    $query "SELECT username FROM users WHERE (hostid='" $y "') LIMIT 1";
        
    $result mysql_query ($query);
        while (
    $row mysql_fetch_array($result))
        {
        
    $host$row["username"];
        }
        
    $hostid $y;
          
          echo 
    "<b>$host</b> - Notifly Registration";
          
    ?>
          <form action="index.php?option=friends&task=register" method="post">
           <label>Username: </label>
           <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" size="30" maxlength="30" /><br />
           <label>Aim: </label>
          <input type="text" name="aim" value="<?php if (isset($_POST['aim'])) echo $_POST['aim']; ?>" size="30" maxlength="30" /><br />
           <label>Email: </label>
           <input type="text" name="email" size="30" maxlength="40" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>" /><br />
           <input type="hidden" name="hostid" value="<?php echo "$hostid"?>" />
           <label>I agree to terms and conditions</label><br />
           <input type="checkbox" name="agree" id="agree" value="1"/><br />
           <input type="submit" name="submit" value="Submit" />
           <input type="hidden" name="registered" value="TRUE" />
          </form>
          <?
          
    } else {
          echo 
    '<b>Could not find user, check the link again!</b>';
          }
        } 
    ?>
    The Check

    PHP Code:
    <?php
    $option 
    = isset($_REQUEST['option'])!=''?$_REQUEST['option']:'';
    $task = isset($_REQUEST['task'])!=''?$_REQUEST['task']:'';

    //$option = 'friends';
    require_once('includes/connection.php');
    require_once(
    'all.php');

    if( 
    $_REQUEST['task']=='register'){

        if (isset(
    $_POST['registered'])) {
        
        
    $host $_POST['host'];
        
    $hostid $_POST['hostid'];

        
    $errors = array();

        if (
    eregi('^[[:alnum:]\.\'\-]{4,30}$'stripslashes(trim($_POST['username']))) ) {
            
    $username mysql_real_escape_string($_POST['username']);
            
    $query "SELECT username FROM friends WHERE username = '$username'";
            
    $result = @mysql_query($query);
            
    $num = @mysql_num_rows($result);
            if (
    $num0) {
                
    $errors[] = '<font color="red">The username you have chosen has already been taken, please try again.</font>';
            } else {
                
    $username mysql_real_escape_string($_POST['username']);
            }
        } else {
            
    $errors[] = '<font color="red">Please provide a valid username between 4 and 30 characters.</font>';
        }
        
        if (
    eregi('^[[:alnum:]\.\'\-]{4,30}$'stripslashes(trim($_POST['aim']))) ) {
            
    $aim mysql_real_escape_string($_POST['aim']);
            
    $query "SELECT aim FROM friends WHERE aim = '$aim'";
            
    $result = @mysql_query($query);
            
    $num = @mysql_num_rows($result);
            if (
    $num0) {
                
    $errors[] = '<font color="red">The Aim Screen Name is already been taken.</font>';
            } else {
                
    $aim mysql_real_escape_string($_POST['aim']);
            }
        } else {
            
    $errors[] = '<font color="red">Please provide a valid Aol Screen Name.</font>';
        }
        
        
    //Email
        
    $email $_POST['email'];
      if (!
    ereg("^[^@]{1,64}@[^@]{1,255}$"$email)) {
        
    $emailbad true;
      }
      
    // Split it into sections to make life easier
      
    $email_array explode("@"$email);
      
    $local_array explode("."$email_array[0]);
      for (
    $i 0$i sizeof($local_array); $i++) {
        if
    (!
    ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
    ?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$"
    ,
    $local_array[$i])) {
            
    $emailbad true;
        }
      }
      
      if (!
    ereg("^\[?[0-9\.]+\]?$"$email_array[1])) {
        
    $domain_array explode("."$email_array[1]);
        if (
    sizeof($domain_array) < 2) {
            
    $emailbad true;
        }
        for (
    $i 0$i sizeof($domain_array); $i++) {
    if(!
    ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
    ?([A-Za-z0-9]+))$"
    ,
    $domain_array[$i])) {
            
    $emailbad true;
          }
        }
      }
      if (
    $emailbad == true) {
       
    $errors[] = '<font color="red">Please supply us with a valid email.</font>';
       }
      
    //END OF FILTER 
    //check the check box
         
    if(!isset($_POST['agree'])) {
    $errors[] = '<font color="red">You must agree to terms and conditions.</font>';
    }

        
    //Check if we have no errors
        
    if (empty($errors)) {
            
    $query "INSERT INTO friends (username, aim, email, hostid) VALUES ('$username', '$aim', '$email', '$hostid')";
            
    $result = @mysql_query($query);
            if (
    mysql_affected_rows() == 1) {
                            
    // Send the E-Mail
                            
    $body "Thank you for registering at Notifly. To activate your account, please click on this link:\n\n";
                    
    $body .= "http://www.securewebdesigns.com/Appwarez/activate.php?x=" mysql_insert_id() . "&y=$a";
                
    mail($_POST['email'], 'Registration Confirmation'$body'From: Appwarez.com');
                            
    // Show thank you message
                
    echo '<h1>Thank You</h1>
                You have been registered, you have been sent an e-mail to the address you specified before. Please check your e-mails to activate your account.'
    ;
            } else {
                echo 
    '<font color="red">You could not be registered, please contact us about the problem and we will fix it as soon as we can.</font>';
            }
        } else {
            echo 
    '<br />
            The following error(s) occured:<br />'
    ;
            foreach (
    $errors as $msg) {
                echo 
    " - <font color=\"red\">$msg</font><br />\n";
                }
                echo 
    "<br />\n";
            }
        }
    }
    require_once(
    'friends.html.php');
    ?>
    Last edited by The_Return; 08-22-2009 at 04:00 AM.

  • #2
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    9
    Thanks
    0
    Thanked 4 Times in 3 Posts
    i think that u forgot to set the type of database fields as Text or char
    they may be still an integer value,so any thing that isn't numerical will be 0.

  • Users who have thanked spidershrief for this post:

    The_Return (08-22-2009)

  • #3
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Thanks your right somehow instead of varchar it was int


  •  

    Posting Permissions

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