PHP - What Reserved Variable To Use To Return As Close As Possible To Identity?
I think I might have already asked something similar, but... my code has: $ip = gethostbyaddr($_SERVER['REMOTE_ADDR']); $host = $_SERVER['HTTP_HOST']; my field header for "$host" is "VISITOR DOMAIN ADDRESS". I'm not sure what I was thinking. That's not possible to capture is it? Last I read, and I think someone here told me, it is only possible to capture the IP and server name of the requesting computer? the var $ip in my report, for instance, returns: 173-28-199-198.client.mchsi.com if I visit the page, and that is the name of the server assigned to my ISP. on PHP's doc page, there are the vars REMOTE_HOST and REMOTE_USER and I haven't tried those. Their example does not list any return value for those vars. what do they return? Edited November 23, 2019 by ajetrumpetSimilar TutorialsUndefined variable: return line 38 that line is : echo $return; Below is a look at my full code. Code: [Select] <?php class cms { var $host; var $username; var $password; var $db; function connect() { $con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error()); mysql_select_db($this->db, $con) or die(mysql_error()); } function get_content($id = ''){ if($id !=""): $id = mysql_real_escape_string($id); $sql = "SELECT * FROM cms_content WHERE id = '$id'"; $return = '<a href="index.php">Go Back?</a>'; else: $sql = "SELECT * FROM cms_content ORDER BY id DESC"; endif; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) != 0): while($row = mysql_fetch_assoc($res)) { echo '<h1><a href="index.php?id=' . $row['id'] .'">' . $row['title'] .'</a></h1>'; echo '<p>' . $row['body'] . '</p>'; } else: echo '<p> Sorry! This Page doesn\'t exist!</p>'; endif; echo $return; } }//Ends our class ?> Hello All, I have two php files original.php and return.php retrun.php file returns a variable after I pass $channel_name to it Code: [Select] return $return_variable; I want to assign this return variable to a variable in original.php Something like this Code: [Select] $results = include ('return.php?channel='.$channel_name.'');I am not sure how to do the above code. When I call the return.php from a browser it works properly. Thanks for any help I'm not versed in PHP OOP and I have some code that I need to echo out onto a page. I don't know what the meaning of $ct->something is in this code. Is this an array of some type? How do I echo out the $ct->title onto another page? Use a function call? I just don't know what all of the $ct variables are and how to get to them. Any help is appreciated. Code: [Select] function current_theme_info() { $themes = get_themes(); $current_theme = get_current_theme(); if ( ! isset( $themes[$current_theme] ) ) { delete_option( 'current_theme' ); $current_theme = get_current_theme(); } $ct->name = $current_theme; $ct->title = $themes[$current_theme]['Title']; $ct->version = $themes[$current_theme]['Version']; $ct->parent_theme = $themes[$current_theme]['Parent Theme']; $ct->template_dir = $themes[$current_theme]['Template Dir']; $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir']; $ct->template = $themes[$current_theme]['Template']; $ct->stylesheet = $themes[$current_theme]['Stylesheet']; $ct->screenshot = $themes[$current_theme]['Screenshot']; $ct->description = $themes[$current_theme]['Description']; $ct->author = $themes[$current_theme]['Author']; $ct->tags = $themes[$current_theme]['Tags']; $ct->theme_root = $themes[$current_theme]['Theme Root']; $ct->theme_root_uri = $themes[$current_theme]['Theme Root URI']; return $ct; } Hey, In my script I am currenlty working on I have 2 classes one which calls the second in the hope it will return a value to it but doesnt send the variable back. The example code below give you and idea of what I am looking for as my script it too long to add. Code: [Select] class oneClass{ function bar(){ $var1 = "test" $two = twoClass(); $result = $two->foo($var1); echo $result; } } class twoClass{ function foo($var1){ $result = $var1 . ' is successful!'; $this->fooTwo($result); } function fooTwo($result){ $result = $result . ' Pass me back now?'; return($result); //Want to pass the variable back to "oneClass->bar();" } } // Starts script $testme = new oneClass(); $testme->bar(); This is a very simple example but states what i am wanting to. Any ideas would be much appreciated! Thanks This is object programming right? Is there a performance issue with this? for example: $notfications = ( blah blah ) ? : ''; then if ($notificatiosn != blabla){ echo 'hey'; }or.... $notifications = function(){ do my stuff here then return 'hey'; }Which way is faster or slower? Reason I Ask this is because I've been doing some object orientated programming in javascript, and didn't know you could do it in php. I'd rather do the objective way so I don't have to use so many freaking variables above the regular way, lol. Edited by Monkuar, 22 January 2015 - 12:22 PM. Is 'password' a protected/resevred term in either PHP or HTML? Is this code valid... Quote <li> <label for="password"> <em><img src="images/required.png" alt="required" /></em> Password: </label> <input id="password" name="password" class="text" type="password" /> </li> TomTees I have found postings close, but not close enough to find my error. I am looking up data from a MySql table and putting it in a dropdown box on a form. I can select the item, but apparently not really. I am not able to echo it, or post it to a record. I'm sure I am missing something simple, but... Code attached if anyone can show me the errors of my ways. Thank you. Hey, I wanted to know if there is any difference between catching a return value and assigning into a variable, and just catching the value when when you just simply call the function on its own. Here is what I mean below In the first example I called the return by simple calling the function. In the second example I catched the return value through a variable, and then echoed it out. Code: [Select] <?php // Example 1 function text (){ $string = "this is a string </br>"; return $string;} echo text(); // Example 2 function text (){ $string = "this is a string </br>"; return $string; } $new_value = text(); echo $new_value; } ?> Is this necessary? mysql_close($link); $query = "SELECT * FROM db_one WHERE field1 = '".$MyVar."'"; $results = mysql_query($query); while($line = mysql_fetch_array($results)) { echo $line["a"].",,"; echo $line["b"].",,"; echo $line["c"].",,"; echo $line["d"].",,"; echo $line["e"].",,"; echo $line["f"].",,"; echo $line["g"].",,"; echo $line["h"].",,"; echo $line["i"].",,"; echo $line["j"].",,"; echo $line["k"].",,"; echo $line["l"].",,"; } mysql_close($link); I am trying to create a login menu where senior salesman get redirected to one page and salesman get redirected to another. Hi,
Ive been trying to come up with a simple solution.
I run a scheduled task every 1 minute, it checks for a certain message in a MySQL DB.
If the message is there then i need to access a link such as:
https://www.somedoma...00000&body=This is the SMS to be sent&plaintext=1
This essentially sends an SMS to a user.
both the recipient and the body need to be a variable.
Is there a way then to get PHP to load/run the link without actually opening a browser?
ive been trying to check out allow_url_fopen but i cant seem to find any examples of how this works.
Any info or pointers would be great thanks.
Trying to figure out my game map. Here is what's going on: Any player can view themself on the map and also the user at this location: x:50, y50. For some reason the map will not show anyone else. If you would like to see it, just go to http://www.gglegends.net/map.php and login with the credentials below (only 1 user can be logged in at a time): Credential for Demo Account - (I have restricted areas that affect others gameplay and areas that change the demo account) Username: demo Password: pass Other map locations to try out: x:60, y:60 x:19, y:79 x:98, y:72 x:75, y:51 x:97, y:26 x:66, y:12 Here is the complete code to my map: <?php require 'includes/header.php'; //Check to see if user exists in the map table, if not redirect location to get coordinates $user_map_check_results = $db->query ("SELECT * FROM map WHERE uID=".$user['uID'].""); $user_map_check = mysql_num_rows($user_map_check_results); if ($user_map_check == 0){ echo '<META HTTP-EQUIV="Refresh" Content="0; URL=firstrun.php">'; die(); } //Fetch the largest x coordinate in the map table. $map_size_x_result = $db->query( "SELECT MAX(x) AS map_max_x FROM map" ); $map_size_x = $db->fetch( $map_size_x_result ); //Fetch the largest y coordinate in the map table. $map_size_y_result = $db->query( "SELECT MAX(y) AS map_max_y FROM map" ); $map_size_y = $db->fetch( $map_size_y_result ); //Set map size. Determined by largest x and y coordinates. $grid_x = (int)$map_size_x['map_max_x']; $grid_y = (int)$map_size_y['map_max_y']; //x and y rows to display at a time. $display_rows = (int)10; //Fetch all user locations. $users_map_result = $db->query( "SELECT * FROM map LEFT JOIN users ON map.uID=users.uID" ); $users_map = $db->fetch( $users_map_result ); //Fetch user map location from database. $user_location_result = $db->query( "SELECT * FROM map LEFT JOIN users ON map.uID=users.uID WHERE map.uID=".$user['uID']."" ); $user_location = $db->fetch( $user_location_result ); //default display coordinate if none specified - will be user map location. $x = (int)$user_location['x']; $y = (int)$user_location['y']; $param_x = $_REQUEST["xcord"]; $param_y = $_REQUEST["ycord"]; if (isset($param_x) && isset($param_y)) { //validate that the parameter is a legit point. if (($param_x <= $grid_x) && ($param_x >= 1) && ($param_y <= $grid_y) &&($param_y >= 1)) { $x = (int)$param_x; $y = (int)$param_y; } } //set map location to the center of the map. $display_half = round($display_rows / 2); $other_half = $display_rows - $display_half; //display the target in the middle. $start_x = ($x - $display_half) +1; $end_x = $x + $other_half; //if the $start_x variable is less than 1 the grid would be in the negatives. so set it to 1. if ($start_x < 1) { $start_x = 1; $end_x = $display_rows; } else //if $end_x is off the grid we have to compensate and add the remaining rows to the start. if ($end_x > $grid_x) { $extra = $end_x - $grid_x; $end_x = $grid_x; $start_x = $start_x - $extra; } //same applies for the y axis. $start_y = ($y - $display_half) +1; $end_y = $y + $other_half; //if the $start_y variable is less than 1 the grid would be in the negatives. so set it to 1. if ($start_y < 1) { $start_y = 1; $end_y = $display_rows; } else //if $end_y is off the grid we have to compensate and add the remaining rows to the start. if ($end_y > $grid_y) { $extra = $end_y - $grid_y; $end_y = $grid_y; $start_y = $start_y - $extra; } ?> <b><tl>World Map</tl></b><br /> <img alt="" src="images/seperator.gif" /><br /> Click anywhere on the map to begin moving around. You can click on players name's to view their profile.<br /><br /> Move to Map Location or <a href="map.php"><u>Return to base</u></a>. <?php echo "Current Map Coordinates: X $x - Y $y"; ?><br /> <!-- Search custom coordinates --> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="GET"> <input name="xcord" type="text" size="3" maxlength="2" onblur="if ( this.value == '' ) this.value = this.defaultValue" onfocus="if ( this.value == this.defaultValue ) this.value = ''" value="x"> <input name="ycord" type="text" size="3" maxlength="2" onblur="if ( this.value == '' ) this.value = this.defaultValue" onfocus="if ( this.value == this.defaultValue ) this.value = ''" value="y"> <input type="submit" value="Submit"> </form> <br /><br /> <!-- Show map --> <table width="750" cellspacing="0" cellpadding="1" border="0"> <?php //these 2 for loops represent the y and x axis //using the data collected above the loops will properly display the grid. for ($Ty = $start_y; $Ty <= $end_y; $Ty++) { //start new row echo '<tr>'; for ($Tx = $start_x; $Tx <= $end_x; $Tx++) { //show grid DisplayGrid($Tx,$Ty); } echo '</tr>'; } ?> </table> <?php //Function to disaply the map. function DisplayGrid($grid_x,$grid_y) { global $x, $y, $user_location, $users_map; $bgimg = 'grass.gif'; $building = ''; if ($grid_x == $user_location['x'] && $grid_y == $user_location['y']) { $building = '<img src="images/map/building.gif" alt="" border="0" /><br />'; $user_map_name = '<br /><a href="player_profile.php?id='.$user_location['uID'].'" target="_blank"><u><b>'.$user_location['uLogin'].'</b></u></a><br />'; } if ($grid_x == $users_map['x'] && $grid_y == $users_map['y']) { $building = '<img src="images/map/building.gif" alt="" border="0" /><br />'; $user_map_name = '<br /><a href="player_profile.php?id='.$users_map['uID'].'" target="_blank"><u><b>'.$users_map['uLogin'].'</b></u></a><br />'; } echo "<td width=\"75\" height=\"75\" style=\"background-image: url('images/map/$bgimg');background-repeat: repeat;\" align=center valign=center onclick=\"window.location.href='map.php?xcord=$grid_x&ycord=$grid_y'\">$building $user_map_name</td>"; } require 'includes/footer.php'; ?> hope i'm in the right place. Hello,my name is carlton. i have a html form i created in dreamweaver cs. i have the accompanying .php script to forward user details to the server. i fill in the form, hit the submit button and nothing appears in the table i created. the testing server has been successfully configured the database "babiesnmovies" is recognized by dreamweaver. PLS tell me what i'm missing. below is a copy of the form and the script. Thank you so much. //this is the HTML registration web form i created in dreamweaver// Code: [Select] <legend>Parents Contact Information</legend> </h3> <form id="form1" name="form1" method="PUT" action="babiesnmovies.php"> <p> <label for="babiesnmovies.com/register">Your First Name</label> <input type="text" name="yourfirstname" id="babiesnmovies.com/register" /> <label for="babiesnmovies.com/registered">Your Last Name</label> <input type="text" name="yourlastname" id="babiesnmovies.com/registered" /> </p> <label for="babiesnmovies.com/yourname">Your Phone Number</label> <input type="text" name="yourphonenumber" id="babiesnmovies.com/yourname" /> <label for="babiesnmovies.com/email">Your E-mail</label> <input type="text" name="youremail" id="babiesnmovies.com/email" /> </p> </form> <p> </p> <h3> <legend>Baby's Vitals</legend> </h3> <form id="form2" name="form2" method="PUT" action="babiesnmovies.php"> <p> <label for="babiesnmovies.com/baby'slast">Baby's First Name</label> <input type="text" name="babysfirstname" id="babiesnmovies.com/baby'sfirst" /> <label for="babiesnmovies.com/babies">Baby's Middle Name</label> <input type="text" name="babysmiddlename" id="babiesnmovies.com/babies" /> </p> <p> <label for="babyslastname">Baby's Last Name</label> <input type="text" name="babyslastname" id="babyslastname" /> </p> <p> <label for="babiesnmovies.com/babybday">Baby's Birthdate</label> <input type="text" name="babysbirthdate" id="babiesnmovies.com/babybday" /> <label for="babiesnmovies.com/babyage">Baby's Age</label> <input type="text" name="babysage" id="babiesnmovies.com/babyage" /> </p> <p> <label for="babiesnmovies.com/baby">Baby's Height</label> <input type="text" name="babysheight" id="babiesnmovies.com/baby" /> <label for="babiesnmovies.com/babyweight">Baby's Weight</label> <input type="text" name="babysweight" id="babiesnmovies.com/babyweight" /> </p> <p> <label for="babiesnmovies.com/babyeyes">Baby's Eye Color</label> <input type="text" name="babyseyecolor" id="babiesnmovies.com/babyeyes" /> <label for="babiesnmovies.com/babyhair">Baby's Hair Color</label> <input type="text" name="babyshaircolor" id="babiesnmovies.com/babyhair" /> </p> <p> <label for="babiesnmovies.com/babyrace">Baby's Ethnicity</label> <input type="text" name="babysethnicity" id="babiesnmovies.com/babyrace" /> </p> <p><input name="formsubmit" type="submit" value="Submit" /> </form> //this is the babiesnmovies.php script// <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_babiesnmovies = "XXX"; $database_babiesnmovies = "XXX"; $username_babiesnmovies = "XXX"; $password_babiesnmovies = "XXX"; $babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db("db337879506", $con); $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL','$yourfirstname', '$yourlastname', '$yourphonenumber', 'youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; $yourfirstname = $_POST ['YourFirstName']; $yourlastname = $_POST ['YourLastName']; $yourphonenumber = $_POST ['YourPhoneNumber']; $youremailaddress = $_POST ['YourE-mailAddress']; $babysfirstname = $_POST ['BabysFirstName']; $babysmiddlename = $_POST ['BabysMiddleName']; $babyslastname = $_POST ['BabysLastName']; $babysbirthdate = $_POST ['BabysBirthdate']; $babysage = $_POST ['BabysAge']; $babysheight = $_POST ['BabysHeight']; $babysweight = $_POST ['BabysWeight']; $babyseyecolor = $_POST ['BabysEyeColor']; $babyshaircolor = $_POST ['BabysHairColor']; $babysethicity = $_POST ['Babys Ethnicity']; ?> Thank you. Hey there, I currently have a banning system on my site that doesn't allow users to login with the banned account. But the cookies are set to remember them for a year. How can I destroy their cookie, so that they don't stay logged in and continue to use the site? Hello, I'm having a bit of trouble with the following: <?php echo htmlentities('<img src="<?php bloginfo('template_directory');?>/images/my-image.png" / rel="nofollow">'); ?> As you can see, I am trying to use php to call the template directory but it isn't being recognized as a php statement. I'm new to php and I'm pretty certain my syntax is not right. Can someone provide a bit of guidance? Thank you. Quint Hi there, I was wondering if it is possible to (on the closing of a browser to a logged in user) to automatically destroy that session. Thanks in advance. I have a problem, where i need to know when user leave or close tha browser tab. I tryd to make a ajax post, after unload, make a POST into kill_browser.php and after 1 minute when session_expire, php code will be execute and save time into database. But it not seems to work :/ I'm glad if some 1 can say what im doing wrong, or is there eny better way to detect it.
@home.php
var leaved = 'leaved'; $(window).unload( function(){ $.ajax({ url: 'kill_browser.php', global: false, type: 'POST', data: leaved, async: false, success: function() { console.log('leaved'); } }); }); @kill_browser.php <?php require('class/connection.php'); $conn = new connection(); session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); session_cache_expire(1); $cache_expire = session_cache_expire(); session_start(); $_SESSION['leaved'] = $_POST['leaved']; if($_SESSION['leaved'] == null || $_SESSION['leaved'] == " "){ $conn->logOut($_SESSION['userID'], $_SESSION['userIP'], $_SESSION['LAST_GENERATED_ID']); session_regenerate_id(true); unset($_SESSION); session_destroy(); header('location:index.php'); } ?> I need to close a window if referer not valid, but it cannot be in HTML, needs to be php. This is what I have so far: Code: [Select] if (ereg("http://www.mysite.com/test.php", $_SERVER['HTTP_REFERER']) != true){ header('Location: ?????????'); exit; } I get a header already sent message if I use a URL. I need it to close the window after 3 seconds. Any ideas? hi, im trying to parse this xml file : xml.gamebookers.com/sport /football.xml_attr.xml i want to echo on my page like this : league name 1 match 1 of league 1 odds odds odds match 2 of league 1 odds odds odds . . league name 2 match 1 of league 2 odds odds odds match2 of league 2 odds odds odds . . this is my code so far <?php $xml=simplexml_load_file('http://xml.gamebookers.com/sports/football.xml_attr.xml'); $league=$xml->xpath('//event/..'); // leagues refers to element<group> $matches=$xml->xpath('//bettype[@name="Versus (with Draw)"]/..'); // shows matches name (team versus team) $odds=$xml->xpath('//event/bettype[@name="Versus (with Draw)"]/bet'); //odds of matches 1 x 2 $leaguecount=count($league); $matchescount=count($matches); $oddscount=count($odds); $i=0; while ($i<$leaguecount){ echo $league[$i]['name'].'<br>'; $i++; } echo '<br><br>'; $i=0; while ($i<$matchescount){ echo $matches[$i]['name'].'<br>'; $i++; } $i=0; while ($i<$oddscount){ echo $odds[$i]['odd'].'<br>'; $i++; } ?> it prints this: http://www.mh724.com/school/xp.php so i need something like that: echo league[$i][mathces[$i][odds[$i] // like arrays of array but it does not work of course any help will highly appreciated :shrug: with regardS I have a script there download a lot of images from a website it crawls, but when ever i started a crawler, it will keep downloading images. Even if i close firefox, it will continue to download images from the site. How can i stop it?. |