PHP - Close
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); Similar TutorialsI 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'; ?> 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 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. 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'); } ?> 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? 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?. 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 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 guys, This is very important. The supervisor of my system wants to close accounts which contain zero balances for long time periods. There is a separate page contains ID and Account Number.This is included in a form and a "close account" button is there. When he clicks on that button the relevant record should be deleted from all tables which include that ID. The table structure looks like this. There are 4 account types which contain same fields. savings_investment(ID,account_type,full_name_balance,interest,customer_id) I want full coding of this scenario. Thanks, Heshan This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=355464.0 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 ajetrumpetHi Guys, My 2nd issue with my new blog is that the code used to limit the amount of content displayed from each post, is on occasion truncating the closing html tags along with the excess text! Very often this will result in any following posts being entirely italic or bold, which as you can imagine looks ridiculous. The Code that limits the content: # Limit Post function the_content_limit($max_char, $more_link_text = '', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content, '<h1>,<h2>,<h3>,<strong>,<em>, '); if (strlen($_GET['p']) > 0) { I'd be very grateful if someone could help me out with this. Thanks Steve I'm trying to create an object oriented PHP poll. I know I'm close but I got stuck. If anyone can help me with this. It's a radio button poll: Code: [Select] <html> <head> <title>Polling</title> <head> <body> <h1>Pop Poll</h1> <p>Who will you vote for in the election?</p> <form method=post action="show_poll.php"> <input type="radio" name="vote" value="John Smith">John Smith<br /> <input type="radio" name="vote" value="Mary Jones">Mary Jones<br /> <input type="radio" name="vote" value="Fred Bloggs">Fred Bloggs<br /><br /> <input type=submit value="Show results"> </form> </body> Here is the show_poll.php <?php /******************************************* Database query to get poll info *******************************************/ // get vote from form $vote=$_REQUEST['vote']; // log in to database if (!$db_conn = new mysqli('localhost', 'poll', 'poll', 'poll')) { echo 'Could not connect to db<br />'; exit; } if (!empty($vote)) // if they filled the form out, add their vote { $vote = addslashes($vote); $query = "update poll_results set num_votes = num_votes + 1 where candidate = '$vote'"; if(!($result = @$db_conn->query($query)))//'@' means not showing error message. { echo 'Could not connect to db<br />'; exit; } } else { echo 'You did not vote!<br />'; exit; } // get current results of poll, regardless of whether they voted $query = 'select * from poll_results'; if(!($result = @$db_conn->query($query))) { echo 'Could not connect to db<br />'; exit; } $num_candidates = $result->num_rows;//how many candidates are = the number of rows // calculate total number of votes so far $total_votes=0; while ($row = $result->fetch_object()) { $total_votes += $row->num_votes; } $result->data_seek(0); // reset result pointer ?> <h2>Result:</h2> <table> <tr> <td>John Smith:</td> <td> <img src="poll.gif" width='<?php echo(100*($num_candidates/$total_votes)); ?>' height='20'> <?php echo(100*($num_candidates/$total_votes)); ?>% </td> </tr> <tr> <td>Mary Jones:</td> <td> <img src="poll.gif" width='<?php echo(100*($num_candidates/$total_votes)); ?>'height='20'> <?php echo(100*($num_candidates/$total_votes)); ?>% </td> </tr> <tr> <td>Fred Bloggs:</td> <td> <img src="poll.gif" width='<?php echo(100*($num_candidates/$total_votes)); ?>'height='20'> <?php echo(100*($num_candidates/$total_votes)); ?>% </td> </tr> </table> the Problem:: When I click a candidate it increments the value in the database it gets recorded well but I have problem with showing the result. It doesn't show the result right. I know that the bug lays he Code: [Select] 100*($num_candidates/$total_votes)). Instead of $num_candidates variable I need to come up with another variable that is the number of votes each candidate gets. I don't know how to come up with that. Any help Please help me with this I'd like to have an object oriented solution the point is that I don't want to use "If else" statements. Thanks any help a lot in advance Hello,
I am using this collapse menu from bootstrap:
http://getbootstrap....cript/#collapse
What I did is instead of putting text in the content section I added many links. The links only show up when one of the menu link is clicked.
Now my problem is that in one of the menu sub, there are about 30 links, therefore the user has to go down the page to see the content.
Is there a way to have the menu collapsing on itself when a link is clicked please? Like a reset to reset it like on page load
Thanks all,
Ben
Hi Guys, I am trying to get the below code to work - search form with textbox, dropdown and submit button. I found scripts on the web but the addition of the pagination just causes an error. I spent hours tweaking it but alas I cant see the solution. Perhaps someone could help please. I would love to see an example with 1 textbox, 2 dropdowns and a submit button or a link to such a tutorial. My googling has hit a dead end. In the below code I can run a search and the reults are listed on results.php. Results get screwed up when I go to pagination page 2,3,4 etc...I think i need to integrate $max somewhere in the Code: [Select] $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); Thanks Code: [Select] <h2>Search</h2> <form name="search" method="post" action="results.php"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="fname">First Name</option> <Option VALUE="lname">Last Name</option> <Option VALUE="result">Profile</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> //results.php <? // Grab POST data sent from form $field = @$_POST['field'] ; $find = @$_POST['find'] ; $searching = @$_POST['searching'] ; //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("mysql.yourhost.com", "user_name", "password") or die(mysql_error()); mysql_select_db("database_name") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> <?php if(!isset($_REQUEST['pagenum'])) { $pagenum=1; } else { $pagenum=$_REQUEST['pagenum']; } //Here we count the number of results //Edit $data to be your query $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it //$data = mysql_query("SELECT * FROM topsites $max") or die(mysql_error()); this works with pagination hmmm //This is where you display your query results //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['fname']; echo " "; echo $result['lname']; echo "<br>"; echo $result['info']; echo "<br>"; echo "<br>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> OKKK! good day please i have little problem that is now a mighty one before me. I added a login form to a page using Iframe modal class i got from tinybox2. I have been able to login the user and in use the HEADER function to redirect the user to their user_page but the direction is done in the I-frame and not the parent window. Now my problem is how do i close the iframe and still redirect the user to the next page. I tried some javascript but all to no avail .
THE LOGIN AND I-FRAME PAGE SCRIPT
<?php if(empty($errors)=== true){ $login=login($username, $password); if($login === false){ $errors[]='INVALID LOGIN DETAILS.... PLEASE CHECK YOUR DETAILS AND TRY AGAIN.'; } else{ $_SESSION["user_id"]=$login; ?> <script> parent.window.close();</script> <?php header("location:user_page.php"); } } if(empty($errors)=== false){ $_SESSION["errors"]=$errors[0]; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Login</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <link href="css/signin.css" rel="stylesheet" type="text/css"> </head> <body> <div class="account-container"> <div class="content clearfix"> <form action="#" method="post"> <h1>Member Login</h1> <div class="login-fields"> <p>Please provide your details</p> <div class="field"> <label for="username">Username</label> <input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" /> </div> <!-- /field --> <div class="field"> <label for="password">Password:</label> <input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/> </div> <!-- /password --> </div> <!-- /login-fields --> <input class="login-fields_submit" type="submit" name="login" value="Log In"> </form> <?php if(isset($_SESSION["errors"])){?> <h1 style="background:darkred;margin-bottom:-27px;font-size:9px !important;"> <?php echo $_SESSION["errors"]; unset($_SESSION["errors"]);?></h1><?php }?> </div> <!-- /content --> </div> <!-- /account-container --> </body> </html> I am creating this feature for a client of mine that needs it working by tomorrow! I am trying to use cURL to grab the RSS feed he http://blogs.menshealth.com/fitness-pros/feed But all I get back is an empty string... Please help - I've been searching Google & this forum but haven't found anything that I can use that fixes this issue. $feed = getRssData(); echo "<pre>\n"; print_r( $feed ); echo "\n</pre>\n"; function getRssData() { // returns the feed array $requested_feed = "http://blogs.menshealth.com/fitness-pros/feed"; $ch = curl_init($requested_feed); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $rss_data = curl_exec($ch); curl_close($ch); echo "RSS DATA: <br />\n" . $rss_data; $doc = new DOMDocument(); $doc->load($rss_data); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } return $arrFeeds; } You can see a live test he http://pro-formpt.com/get_rss.php?feed=workout It only has a few parameters in it so I can use the same file to grab other RSS Feeds as well - but they all fail the same way. Like this one: http://pro-formpt.com/get_rss.php?feed=living Which should grab the feed from he http://blogs.menshealth.com/mh-life/feed I truly appreciate any suggestions! Thanks! |