Jump to content

Digiboy

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by Digiboy

  1. Hi guys, I keep getting error for this function: this is the error: Warning: Division by zero in...../..../rating.php and this is my code tried everything I could think of but no success <?php include ('db.php'); function getRating($id,$rating,$click){ $startCount= round($rating/$click); $blankCount=5-$startCount; $ratingHTML=''; for($i=0;$i<$startCount;$i++){ $rate=$i+1; $ratingHTML.='<img src="images/star.png" onclick=changeRating("'.$id.'","'.$rate.'")>'; } for($i=$startCount;$i<5;$i++){ $rate=$i+1; $ratingHTML.='<img src="images/white.png" onclick=changeRating("'.$id.'","'.$rate.'")>'; } return $ratingHTML; } ?> Could you please help m with this? I really appreciate your time in advance.
  2. Just an add on, I have also included session_start() in my header first line
  3. Hi guys, I have an issue with SESSIONS in PHP and tried to find out why for 2 days and no success. This is a login page below divided into to login sections, 1- Facebook Login: Logins successfully, captures user data but wouldn't set sessions. 2- Custom Login: loges in fine and but same issue with sessions. It should create a session and redirect users to user folder if session exists, <?php if (isset($_SESSION['login_token']) && isset($_SESSION['account_no'])) {header('Location:../user/index.php');} //if (!isset($_SESSION['login_token']) || !isset($_SESSION['account_no'])) {header('Location:../login/index.php');} ?> <?php include_once('../library/header.php'); ?> <?php require '../library/facebook.php'; /// login // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => '484846211552634', 'secret' => '1ce89585da85f6c8ff877ab175a144fb', )); $user = $facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(array( 'scope' => 'user_birthday, user_hometown, email,user_location, publish_stream')); } if ($user) { $account_no=mt_rand(); //// check if correct $select=mysql_query("SELECT * FROM users WHERE email='{$user_profile[email]}' AND suspended='1'"); if (mysql_num_rows($select)>=1) { header('Location:../index.php?msg=suspended');} else { $select_account_no=mysql_query("SELECT * FROM users WHERE account_no='$account_no'"); if (mysql_num_rows($select_account_no)==0) { $select_email=mysql_query("SELECT * FROM users WHERE email='{$user_profile[email]}'"); if (mysql_num_rows($select_email)==0) { $account_no=mt_rand(); $login_token=sha1($account_no); $reg_date=date('Y-m-d'); $insert=mysql_query("INSERT INTO users (account_no, first_name, last_name, email, reg_date, city, reg_via, login_token) VALUES ('$account_no','{$user_profile[first_name]}','{$user_profile[last_name]}','{$user_profile[email]}','$reg_date', '{$user_profile[user_hometown]}','1','$login_token')"); $_SESSION['login_token']=$login_token; $_SESSION['account_no']=$account_no; if (mysql_num_rows($select_email)>=1) { $select_my_email=mysql_query("SELECT * FROM users WHERE email='{$user_profile[email]} AND suspended='0''"); while ($row=mysql_fetch_array($select_my_email)) { $myaccount_no=$row['account_no']; $mylogin_token=$row['login_token']; $_SESSION['login_token']=$mylogin_token; $_SESSION['account_no']=$myaccount_no; echo"$myaccount_no"; }}}}} } // This call will always work since we are fetching public data. $naitik = $facebook->api('/naitik'); ?> <?php login(); ?> <div class="box"> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" class="login" method="post" id="login"> <h1 class='-login-title'>Already have an account</h1> <section class="state-normal section-login"> <label for="email">Email</label> <input type="email" name="email" class="validate[required,custom[email]] text-input"/> </section> <section class="state-normal"> <label for="password">Password</label> <input type="password" name="password" class="validate[required] text-input"/> </section> <p><a href="/recovery" title="Recover your password">Can't remember your password?</a></p> <section class="state-normal"> <input type="checkbox" name="checkbox" id="checkbox1" /> <label for="checkbox1">Remember me</label> </section> <button type="button" onclick="window.location = '../register/'" class="color-blue">Create a new account</button> <button type="submit" class="color-grey" name="login">Login</button> </form> <div class="fb"><h1 class='fb-login-title'>Or login with Facebook</h1> <?php if ($user): ?> <a href="<?php echo $logoutUrl; ?>">Logout</a><?php else: ?><a href="<?php echo $loginUrl; ?>"><img src="../img/facebook-connect.png" alt="Connect using Facebook" width="269" height="56" class="fb-connect-button"/></a><?php endif ?> <p class="text-central">Skip registration using your Facebook Account</p> </div> <?php include_once('../library/footer.php'); ?>
  4. Hi guys, I am building a back end for personal project, I need to upload image via back end and need to know how to rename file before upload to its name but with md5 encryption $file=$_FILES['image']['tmp_name']; $image= addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name= addslashes($_FILES['image']['name']); move_uploaded_file($_FILES["image"]["tmp_name"],"../img/ga/" . $_FILES["image"]["name"]); Thanks in advance to you all.
×
×
  • 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.