Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. ok, heres the revised function:

    <?php
    function register(){
    $response = array();
    $connect = mysql_connect("localhost", "username", "password");
    if(!$connect){
    	$response[] = mysql_error();
    	return $response;
    }
    
    $select_db = mysql_select_db("db_name", $connect);
    if(!$select_db){
    	$response[] = mysql_error();
    	return $response;
    }
    
    $first =  mysql_real_escape_string ($_POST['first']);
    $last =  mysql_real_escape_string ($_POST['last']);
    $email = mysql_real_escape_string ($_POST['email']);
    $user =  mysql_real_escape_string ($_POST['username']);
    $pass =  mysql_real_escape_string ($_POST['password']);
    $conf_pass = mysql_real_escape_string ($_POST['conf_pass']);
    $ip = $_SERVER["REMOTE_ADDR"];
    
    if(empty($username)){
    	$response[] = "Please enter your username!";
    }
    if(empty($password)){
    	$response[] = "Please enter your password!<br>";
    }
    if(empty($conf_pass)){
    	$response = "Please confirm your password!<br>";
    }
    if(empty($email)){
    	$response[] = "Please enter your email!";
    }
    
    $user_check = mysql_query("SELECT username FROM members WHERE username='$username'");
    $do_user_check = mysql_num_rows($user_check);
    
    $email_check = mysql_query("SELECT email FROM members WHERE email='$email'");
    $do_email_check = mysql_num_rows($email_check);
    
    if($do_user_check > 0){
    	$response[] = "Username is already in use!";
    }
    
    if($do_email_check > 0){
    	$response[] = "Email is already in use!";
    }
    
    if($password != $conf_pass){
    	$response[] = "Passwords don't match!";
    }
    
    if(count($response) > 0 ){
    	return $response;
    }else
    {
    $insert = mysql_query("INSERT INTO members (`id`, `first`, `last`, `username`, `password`, `email`, `regIP`) VALUES (NULL , '$first', '$last', '$email', '$user', md5('$pass'), '$ip')"); 
    if(!$insert){
    	$response[] = "There's a little problem: ".mysql_error();
    } else { $response[] = "Congrats " . $username . "! You are now registered"; }
    return $response;
    }
    
    
    
    }
    

     

    how exactly are you executing this function, i cant see anyway for you to passs the data to the function. is the form on the same page as the function, and if it is you will need something like this at the top of the page:

    if($_POST['Register']){
    	$response = register();
    }
    

    otherwise the function will never trigger. also the last part of the form will now need to handle an array:

     

    <?php if(isset($response)) echo "<p class='alert'>" .
    
    foreach($response as $r){
    	print $r.'</br>';
    }
    
    . "</p>"; ?>
    

  2. your missing a comma between these two variables:

    , '$email' '$user',

    should be

    , '$email' , '$user',

    also you are trying to build up an error response, ie:

    if(empty($email)){
    	$response = "Please enter your email!";
    }

     

    but you are not using the response variable correctly. just before you do the insert query you should be checking if response has a value, and if it does then dont execute the insert

  3. grand total should start as an int or float, not as a string, and you need to make sure you are adding a number to a number, and that total is not returning a string - example:

    $grandTotal = 0;
    foreach($something as $sum){
    $total = $total +$sum;
    $grandTotal += (float)$total;
    }
    
    

  4. phpretarded, i highy doubt thorpe needs to read up on encryption,seeing as he knows what he's talking about, but seeing as you want throw some insults around i would advise that YOU do some reading up on encryption as AES_DECRYPT and AES_ENCRYPT are both MYSQL functions and not PHP, so trying to meld them into a php statement is not going to work. you need to decrypt it in the sql statement.

     

    he forums here to help people with issues, not to insult one another. If you want to do that then by all means toddle of to facebook

  5. heres an example:

     

    SELECT details.* FROM Person INNER JOIN details USING(user_id) WHERE Person.user_id = 123
    

    In plain english you are saying select everything from the details table where the user_id stored in the details table matches the one in the person table ADN where the persons user_id equals 123

  6. you will find that one of the most popular javascript frameworks used at the moments is JQuery. You should look into using that. I personally despise dreamweaver, and find it an appalling environment to code in. If you are looking for an IDE that supports javascript you can look at Aptana studio, spket and netbeans as alternatives to dreamweaver.

     

    But, even if you learn to use jquery , it is no replacement for learning the native javascript language too.

  7. you need to have a look at using a combination of PHP and AJAX, usually with something like JQUERY for managing the ajax. this will allow you to asynchronously refresh different areas of a page without having to reload 

  8. you need to serialise the data before you put it into the database:

     

    <?php
    //preparing for inserting into db
    $array = array(1,2,3,4,5,6,7);
    $readyForDb = serialize($array);
    
    //extracting from db
    $array = unserialize($row['from the db']);
    

  9. <form id="form1" name="form1" method="post" action="getdetails.php">
    
      <input type="submit" name="Get Details" value="Get Details" />
       </label>
       
      </p>
    </form>
    

    should be something like:

    <form id="form1" name="form1" method="post" action="getdetails.php">
       username <input type="text" name="textfield" value ='' />
      <input type="submit" name="Get Details" value="Get Details" />
       </label>
       
      </p>
    </form>
    

  10. your trying to echo php within a string you are already building in php. try:

    <?php
    $imgsrc =  get_post_custom_values("tj_video_img_url");               
    $igitwid_output .= '<div id="igit_wid_rpwt_main_image"  style="float:left;">
    <a href="' . get_permalink($igitwid_result->ID) . '" target="_top"><img src="'. $imgsrc[0] .'" id="igit_rpwt_thumb" ></a></div>';

    as the last two lines of your code

  11. You will more than likely to listen for the keypress events being triggered, then when the Enter key i used trigger the send, so something like this:

    
          var  message = $('#newMessage');
            var code =null;
            message.keypress(function(e)
            {
                code= (e.keyCode ? e.keyCode : e.which);
                if (code == 13) { //code 13 is the enter key
                  // run the send message event
                     }
                e.preventDefault();
            });

     

    so you will be basically binding the listener to any even to do with the message window. hope this helps point you in the right direction

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.