PHP - Link The Reference Id With User
Dear All,
Am new to PHP. now i want to online cargo tracking system in php. in that i create the reference id for each user to track the shipments. in that user must login and track the shipments. now i need the code for the specific user only view they shipments only. the other user can't be check the other shipments. so i need how to link the user and reference id. kindly advice me. Similar TutorialsI have hardware setup to preform an action on camera when i enter a url into the address bar. Pretty much you will be able to feed tarantulas. I'd like to setup a button that my user can click that will active the url without being moved off of the current page. I can't figure out how to stop the browser from following the link to a blank page. It messes the whole thing up because the feeder only runs for a second and if you get sent to the blank page and have to navigate back the the live video feed page you could miss the feeding. Thanks for the help Hey everybody,
I'm a noob when it comes to PHP so I have a few questions.
I'm in the planning stages for a new website and I need it to do something but I'm not sure how. People would have to log into my website in order to make a purchase and I need to be able to link their account with the software they bought. Think of it like a bit like Steam, you buy the game and its right there in your library.
The way I see it working is they buy their software and when they look in their profile they see a list of the stuff they've bought and have the ability to open it.
The Ecommerce company I'm looking to sign up with to make the transactions and keep the money side of it in order (FastSpring) don't have a way of tracking user purchases so I have to come up with a way of doing my end.
What I would like to know is what language is best to do this? I assume PHP would be the best especially considering the website itself is likely to be built in WordPress.
Secondly does anybody have any links to articles, videos or tutorials on this as I have not been able to find any all afternoon. I know they're going to be out there but I'm not having any luck finding them
Thanks for your time
guys this function below posts the data into table and im also able to send a link in email with caregory name but the issue is getting the id to the particular post i got no isea how do i get that? Code: [Select] function insert($postData) { $postData['description'] = clean($postData['description']); if(!EmailExists($postData['email'])){ $sql = " INSERT INTO tbl_emails SET email = '".$postData['email']."', postersname = '".$postData['postersname']."', phone = '".$postData['phone']."' "; executeSql($sql); } if(empty($_FILES['image']["name"])){ $sql = " INSERT INTO tbl SET title = '".$postData['title']."', image = '', postersname = '".$postData['postersname']."', category = '".$postData['category']."', type = '".$postData['type']."', state = '".$postData['state']."', location = '".$postData['location']."', email = '".$postData['email']."', phone = '".$postData['phone']."', description = '".$postData['description']."', time = '".time()."' "; executeSql($sql); }else{ global $uploadPath; $remove_symbols = array('+', '=', '-', '{', '}', '$', '(', ')','&'); $removed_symbols = str_replace($remove_symbols, "_", $_FILES['image']['name']); $randomnum=rand(00000000,99999999); $imagepath = uploadFile($_FILES['image'], $uploadPath); $image = new SimpleImage(); $image->load($imagepath); $image->resize(250,280); $resize_rename = $uploadPath.$randomnum._.$removed_symbols; $image->save($resize_rename); unlink($imagepath); //delete the original file $sql = " INSERT INTO tbl SET title = '".$postData['title']."', image = '".$resize_rename."', postersname = '".$postData['postersname']."', category = '".$postData['category']."', type = '".$postData['type']."', state = '".$postData['state']."', location = '".$postData['ocation']."', email = '".$postData['email']."', phone = '".$postData['phone']."', description = '".$postData['description']."', time = '".time()."' "; executeSql($sql); } } I am having problems understanding the reason for why the user has to click logout twice, here's the bulk of the code: <?php ini_set('display_errors',0); require_once 'header.html'; require_once 'db.functions.php'; require_once 'config.php'; $database = dbConnect($host, $username, $password, $database); // should output 1 or nothing at all! if($database == true) { // now connected? // carry on with logic of outputting the blog contents: $result = entries("SELECT * FROM entries"); printf("<table>"); while($row = mysql_fetch_array($result)) { printf(" <tr> <td>%s</td> <td>%s</td> </tr> <tr> <td colspan=\"2\">%s</td> </tr> ", $row[2], $row[4], $row[3]); } printf("</table>"); printf("\n\n"); session_name("jeremysmith_blog"); session_start(); if(array_key_exists('login',$_SESSION)) { if($_SESSION['login'] == 1) // change this to correspond with session on the login.php script { printf("<p>Welcome %s</p> <p>To logout, click <a href=\"index.php?action=logout\">here</a></p> ",$_SESSION['username']); } } else { printf("<p>You are not logged in, please click <a href=\"login.php\">here</a> to login.</p>"); } } else { printf("\n<p id=\"error\">Could not connect to database, please try again later.</p>"); } // init the logout script? if(array_key_exists('action',$_GET)) { if($_GET['action'] == 'logout') { // log user out of the system: unset($_SESSION['login']); unset($_SESSION['username']); session_destroy(); } } printf("\n"); // just for output format! require_once 'footer.html'; Why does the user have to click logout twice, have I missed anything? Any helps appreciated thanks. Hi all, I have been coding in PHP for a fair while now and I have come across variables by reference, but I don't really know: a) how they work; b) when to use them; c) why they are used; Can anyone here please clarify these issues please. Thanks in advance! Hi, I just need someone to check that a couple of lines I've written do what I believe them to do... i.e. check my logic! I'm developing a booking form for booking on events. Each booking needs a unique reference, which needs to be meaningless to the customer, so I am BASE36 encloding it. As the booking is be saved to a MySql database, my approach is to use the auto-incremented ID for the record to make the reference unique. The increment starts at 10000, and I add a random number before coding to make the encoded reference longer. I then BASE36 encode it to make it appear random. Am I right in thinking the reference produced WILL be unique ... provided the auto-inc ID is unique? $ref = rand(100,999) . $auto_incremented_id; //e.g. 354 & 10012 = 35410001 $ref_encoded = strtoupper(base_convert($rand, 10, 36)); // e.g.UD4J8P Thanks Hello, I've just started learning PHP, JavaScript and I've got a big problem on my website. I'm getting this ReferenceError. I know what's the problem, but I don't know how to solve it, and I know people can do it for money but I don't have money, I'm searching for someone who's willing to help newbie. As I said I'm begginer, and I know something. The main problem is because I want to use GKPlugin and Player(jwplayer). Plugin need to use object, example:
<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object>Script is generetad just to embed with iframe, and the problem is when I replace it with object, then I'm getting this error. I know that JS can't "call" that iframe to show because I've replaced it with object. You guys probably know about what I'm talking. I'm just searching for some instructions, guidelines from you. ReferenceError: embeds is not defined if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){Here's the rest of code, I think it's used to show iframe. elseif (substr_count($link,"gorillavid")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="http://www.kiinc.com/videott/player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object>'; This is the original code. Don't look at providers(source as gorillavid) because I used gorillavid in previous an posted another example from another source (zalaa) elseif (substr_count($link,"zalaa")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<IFRAME SRC="http://www.zalaa.com/embed-'.$video_id.'.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH='.$width.' HEIGHT='.$height.'></IFRAME>'; Function which embed links and should embed GKPlugin/Player: // general image link if (!$embed){ $embed = "<div style='background-color:#000000; width: ".$width."px; height: ".$height."px;text-align:center;cursor:pointer;' onclick='window.open(\"$link\");'>"; $embed.= "<p style='text-align:center; padding-top: 70px;'>"; $embed.= "<a href='$link' target='_blank' style='font-size:24px; color: #ffffff !important'>Click here to play this video</a>"; $embed.= "</p>"; $embed.= "</div>"; } return $embed; } JavaScript code: function getEmbed(embedid){ if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){ var html_content = "<div class='fake_embed' id='fake_embed"+embedid+"' onclick='closeFakeEmbed("+embedid+");'>" + "<br /><br />" + "<div class='fake_embed_ad_close'><a href='javascript:void(0);' onclick='closeFakeEmbed("+embedid+");'>Close Ad</a></div>" + "<div class='fake_embed_ad' id='fake_embed_ad" + embedid +"'>" + "<iframe src='"+baseurl+"/iframe_ad.php' width='300' height='300' frameborder='NO' border='0'></iframe>" + "</div>" + "<div class='fake_embed_bar'><span class='fake_embed_bar_right'></span></div>" + "</div>" + "<div id='real_embed"+embedid+"' style='display:none'>"+embeds[embedid]+"</div>"; jQuery('#videoBox'+embedid).html(html_content); jQuery('#videoBox'+embedid).show(); } else { jQuery('#videoBox'+embedid).html(embeds[embedid]); jQuery('#videoBox'+embedid).show(); } } function countDown(embedid){ showCounter = showCounter-1; jQuery('span#counter').html(showCounter); if (showCounter>0){ showTimer = setTimeout('countDown('+embedid+');',1000); } else { showTimer = null; showCounter = 20; getEmbed(embedid); } } function changeEmbed(embedid, counter){ if (counter == 0){ jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); getEmbed(embedid); } else { if (showTimer){ clearTimeout(showTimer); } showTimer = null; showCounter = counter; jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); jQuery('#videoBox'+embedid).html(js_lang.ticker); jQuery('#videoBox'+embedid+' span#counter').html(showCounter); jQuery('#videoBox'+embedid).slideDown("slow"); showTimer = setTimeout('countDown('+embedid+');',1000); } /* jQuery('li.selected').removeClass('selected'); jQuery('#selector'+embedid).addClass('selected'); */ } hello. say i have list and i want the correct children under each parent so i have $id $parent_id $type $name in the db i have 4 parents each with 2 children id=1 - type=parent - parent_id=0 - name=p1 id=2 - type=parent - parent_id=0 - name=p2 id=3 - type=parent - parent_id=0 - name=p3 id=4 - type=parent - parent_id=0 - name=p4 id=5 - type=child - parent_id=1 - name=c1 id=6 - type=child - parent_id=1 - name=c2 id=7 - type=child - parent_id=2 - name=c3 id=8 - type=child - parent_id=2 - name=c4 id=9 - type=child - parent_id=3 - name=c5 id=10 - type=child - parent_id=3 - name=c6 id=11 - type=child - parent_id=4 - name=c7 id=12 - type=child - parent_id=4 - name=c8 so how would i do the code? i thought i could do it like this but its not working. Code: [Select] <?php $family = Family::find_all(); foreach($family as $familys){ $id = $familys->id; $type = $familys->type; $parent_id = $familys->parent_id; $name = $familys->name; echo' <ul>'; if($type == "parent"){ echo $name; } echo' </ul> <li>'; if($type == "child" && $parent_id == $id){ echo $name; } echo' </li>'; } ?> all i get back is p1 p2 p3 p4 no children ?? if i remove Quote $parent_id == $id from Quote if($type == "child" && $parent_id == $id){ i get this p1 p2 p3 p4 c1 c2 c3 c4 c5 c6 c7 c8 but they are not listed under the correct parent i also tried moving the </ul> to the bottom but i get the same Code: [Select] <?php $family = Family::find_all(); foreach($family as $familys){ $id = $familys->id; $type = $familys->type; $parent_id = $familys->parent_id; $name = $familys->name; echo' <ul>'; if($type == "parent"){ echo $name; } echo' <li>'; if($type == "child"){ echo $name; } echo' </li> </ul>'; } ?> any thoughts? thanks rick Can someone explain this strange behavior: $aArray = array( 1 => null, 2 => null, 3 => null, ); foreach($aArray as $key => &$val) { $val = "Some Value"; foreach($aArray as $Xkey => $Xval){} // Second foreach } var_dump($aArray); Rsult is: array(3) { [1]=> string(10) "Some Value" [2]=> NULL [3]=> NULL } It looks like second foreach breaks reference, why? hi, i have made a website where people resgister their details of them and products. they have to enter the following details in form Name of company name of the product company address email id password mobile number contact and brief details about their company
user can then login with email id and pwd. now after login ..user will get a page where he can upload the photos of products images and their price, so now my question is that when he finishes uploading (|by clicking on upload button) the product images and price text box ..then on final uploaded webspage it should show all other things which he registerd before (company name , mobile number etc) along with images and price...hence the main question that user does not need to enter mobile and address while uploading images and filling proce ..but on the final page it should show mobile and address along with price and images..as user is not going to enter mobile and address again and again as he will have multiple products to upload.
I would appreciate your assistance, there are tons of login scripts and they work just fine. However I need my operators to login and then list their activities for the other operators who are logged in to see and if desired send their clients on the desired activity. I have the login working like a charm and the activities are listed just beautifully. How do I combine the two tables in the MySQL with PHP so the operator Logged in can only make changes to his listing but see the others. FIRST THE ONE script the member logges in here to the one table in MSQL: <?php session_start(); require_once('config.php'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $login = clean($_POST['login']); $password = clean($_POST['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); if($result) { if(mysql_num_rows($result) == 1) { session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: member-index.php"); exit(); }else { header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> ................................................. ................................ Now I need the person who logged in to the table above to be able to make multiple entries to the table below <? $ID=$_POST['ID']; $title=$_POST['title']; $cost=$_POST['cost']; $activity=$_POST['activity']; $ayear=$_POST['aday']; $aday=$_POST['ayear']; $seats=$_POST['special']; $special=$_POST['seats']; mysql_connect("xxxxxx", "xxx350234427", "========") or die(mysql_error()); mysql_select_db("xxxx") or die(mysql_error()); mysql_query("INSERT INTO `activity` VALUES ('ID','$title', '$cost','$activity', '$aday', '$ayear', '$special', '$seats')"); Print "Your information has been successfully added to the database!" ?> Click <a href="member-profile.php">HERE</a> to return to the main menu <?php ?> Hi, so far I have managed to set up a somewhat basic login website with a mysql database backend. Once they have logged on they go to a "main menu" page. What I need to define is that user A sees button A but only that button, etc. (Then of course that same rule would have to apply if they tried to directly go to the page, but I am guessing I can do that in the same way that I currently do to force a login). If anyone has any tutorials or sample code I would much appreciate it. Thanks, Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after OK, so I have the following file that has database functions: <?php function dbDelete($param){ $conDelete = mysql_connect($url,'username','password',true); mysql_select_db('my_db',$conDelete); mysql_query($param,$conDelete); mysql_close(); if(isset($conDelete)){ mysql_close($conDelete); } } ?> I include the above file in a session handling file. But for some reason the new file can't call the above function as follows: <?php include_once 'the above stated file'; function timeOut(){ dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'"); $_SESSION = array(); setcookie(session_name(),'',time()-4200); session_destroy(); } //CHECK FOR TIMEOUT REQUEST switch($_GET['xyz']){ case 'timeout': timeOut(); header("Location: /?xyz=timedout"); break; case 'logout': timeOut(); header("Location: /?xyz=loggedout"); break; case 'refresh': dbUpdate("UPDATE acctussessi SET acctussessi_time = ".time()." WHERE acctussessi_unid ='".$token."'"); break; } ?> dbDelete isn't being called inside of the TimeOut() function. The only way it works is by doing the following: <?php function timeOut(){ $_SESSION = array(); setcookie(session_name(),'',time()-4200); session_destroy(); } //CHECK FOR TIMEOUT REQUEST switch($_GET['xyz']){ case 'timeout': dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'"); timeOut(); header("Location: /?xyz=timedout"); break; case 'logout': dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'"); timeOut(); header("Location: /?xyz=loggedout"); break; case 'refresh': dbUpdate("UPDATE acctussessi SET acctussessi_time = ".time()." WHERE acctussessi_unid ='".$token."'"); break; } ?> But this is annoying and repetitive. What is going on? Thanks in advance. Is it possible to get something as a reference in the script if it is such a http://site.com/home#p1 tried in different ways but #p1 my script does not see If getValue is given a path which doesn't exist, I can use the isset check to return null. I can also use the uncommitted $tmp =&$tmp[$key];. Why does this prevent an undefined index warning?
public function getValue(string $path) { $path=explode('.', $path); $tmp=$this->config; foreach($path as $key) { //if(!isset($tmp[$key])) return null; //$tmp =$tmp[$key]; $tmp =&$tmp[$key]; } return $tmp; }
I am writting a php function that uses mysql to get user data - pretty common, right Well, my issue is that I need to run a check in my file system. Users profile pictures are stored in my image directory as .png's. I need to have my function check that directory and if an image matches their id, then return their information. I only want the user data if they have an image uploaded. Here is my current function: Code: [Select] function fetch_users_login($limit) { $limit = $limit(int); $sql = "SELECT `users`.`id`, `users`.`firstname`, `users`.`lastname`, `users`.`username`, `user_privacy`.`avatar` FROM `users` LEFT JOIN `user_privacy` ON `users`.`id` = `user_privacy`.`uid` WHERE `users`.`status` > 2 AND `user_privacy`.`avatar` = 1 ORDER BY `users`.`id` DESC LIMIT 0, {$limit}"; $result = mysql_query($sql) or die(mysql_error()); $users = array(); $i = 0; while(($row = mysql_fetch_assoc($result)) !== false) { $users[$i] = array( 'id' => $row['id'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], ); $users[$i]['avatar'] = getUserAvatar($row['username']); $i++; } return $users; } Hi everyone, This is driving me crazy. I need to reference different files located in different folder structure. For example, I have the following file structure. /my_project/ /my_project/database/database_script.php /my_project/index.php 1. If I want to reference /my_project/index.php from /my_project/database/database_script.php, how can I reference it ? 2. From /my_project/index.php to /my_project/database/database_script.php , it's obvious all I gotta do it include("/database/database_script.php"). I use $_SERVER('DOCUMENT_ROOT"), to solve the 1. problem. It works on my XAMPP local machine but when I uplode it onto the server, there's a problem. The path becomes '/my_project/my_project/database/database_script.php". Is there a universal way (more like a standard way) to reference files in php so that I won't need to change every file path once I upload those onto the server ? Regards, Hi Guys Probably a simple answer to this. Writing a script where I have a foreach to escape data in a multi dimensionsal array - destined for the database. I want to preserve the the escaped values in the array so I've passed in the value by referece. See code below: Code: [Select] foreach($myarray as $key=>$value){ foreach($value as $k=>$v){ $v = $mysqli->real_escape_string(&$v); echo $v ."<br/>"; } } I've switched on error_reporting(E_STRICT), because i read it was good practice to build your scripts with this on. Anyway - when i pass by reference I get a message as follows: Quote Deprecated: Call-time pass-by-reference has been deprecated in C:\wamp\www\wh\C.php on line 105 So if pass by reference is deprecated, what's the alternative? I realise i could pass the new values to a new array. But does this mean i shouldn't pass by reference anymore? Many thanks and sorry for going round the planet to ask such a simple question. Drongo Hi all, I'm trying to understand passing by reference. Here is a copy of the code and the results: Code: [Select] <?php $a1 = 15; $b1 = 20; echo addone($a1, $b1); echo "<br/>"; function addone($n1, $n2){ $n1 = $n1 += 2; $n2 = $n2 += 2; return $n1 . " " . $n2; }; echo addonetwo($a1, $b1); function addonetwo($n1, $n2){ $n1 = $n1 += 2; $n2 = $n2 += 2; return $n1 . " " . $n2; } ?> The result output is: 17 22 17 22 If I change the code to add "&" before the "addone" function: Code: [Select] function addone(&$n1, &$n2){ $n1 = $n1 += 2; $n2 = $n2 += 2; return $n1 . " " . $n2; }; Then the output is: 17 22 19 24 I don't understand what's going on. Why is the "&" incrementing the changed variable and in the first example it's incrementing the variables as defined. |