Jump to content

Worqy

Members
  • Posts

    120
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

Worqy's Achievements

Member

Member (2/5)

0

Reputation

  1. It is returning everything I wan't it to.. But as you can see from the code in the first post, $a is a user input and I would wan't it to get from a div that the user selects
  2. Worked, thanks! I've tried all I know to this problem, but its been some months since I coded PHP, so I might have forgot something. This line: preg_match_all('#<div id="intro">(.*?)</div>#sim', $page_all, $div_array); should look like this: <div id=$a> etc.. But I cant get it to work!
  3. Now the output is even more: I just wan't the text inside the <div> tags.
  4. Hi. I found this code for my website, and it work well. Its just that there comes some text I wan't to delete. Code: <?php /* index.php */ Session_start(); if($_SESSION['login'] == false) { header("Location:login.php"); } $a = $_GET['a']; $source='http://****.elementfx.com/test.php'; //$source='sample.txt'; $page_all = file_get_contents($source); $div_array=array(); preg_match_all('#<div id="intro">(.*?)</div>#sim', $page_all, $div_array); //print_r($div_array); ?> <html> <head> <title>Home</title> </head> <body> <center> <p><b><font color="blue" size="20">*****</font></b> <font color="blue" size="2">version 0.9_01</font></p> <br/> <br/> <br/> <textarea cols="50" rows="10"><?php print_r($div_array[1]);?></textarea> </center> </body> </html> The text it should get is: But the output is: I need to get rid of the Array( [0]... thing.. Regards Worqy
  5. I havent been online for some days now because my PC crashed. I'm still in the same place, havent made any progress on the problem. Hope there is someone that want to help me with this! //Kevin
  6. Now I have found the problem. I tested a bit with this code: checkstatus.php .... $_SESSION['test'] = 'kevin'; .... main.php .... echo $_SESSION['test']; .... And it worked perfectly, so I think the problem in the real code is here: checkstatus.php .... $_SESSION['username'] = $info['username']; .... I think my code works, but that the session S1username 's value is nothing. Full code: checkstatus.php <?php // Server 1, checklogin.php Session_start(); include "connect.config.php"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select Database"); $data = mysql_query("SELECT * FROM `resoreces`") or die(mysql_error()); Print "<table border cellpadding=3>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<th>Username:</th> <td>".$info['username'] . "</td>"; Print "</tr><tr>"; Print "<th>Gold:</th> <td>".$info['gold'] . "</td>"; Print "</tr><tr>"; Print "<th>Three:</th> <td>".$info['three'] . "</td> "; Print "</tr><tr>"; Print "<th>Clay:</th> <td>".$info['clay'] . "</td> "; Print "</tr><tr>"; Print "<th>Iron:</th> <td>".$info['iron'] . "</td> "; Print "</tr><tr>"; Print "<th>Wheat:</th> <td>".$info['wheat'] . " </td>"; Print "</tr>"; $_SESSION['S1username'] = $info['username']; } ?> <html> <body> <a href="main.php">Back</a> </body> </html> <?php Print "</table>"; ?> main.php <?php // Server 1, main.php Session_start(); if($_SESSION['LoginS1'] == false) { ?> <html> <head> <title>Access denied!</title> </head> <body> <center>Access denied!</center> <p> Please login to view this site! <p> <a href="/Game/login.php">Login</a> </body> </html> <?php } else { ?> <html> <head> <title>Welcome</title> </head> <body> <center> <?php echo 'Username: '; echo $_SESSION['S1username']; ?> </center> <p> <center><a href="checkstatus.php">Check</a></center> <a href="/Game/logout.php">Logout</a> </body> </html> <?php } ?> So anyone here witha solution for the S1username session problem?
  7. Hmm... I really dont understand anything about this... Is not there a easyer way, like in; Just get the data from the session and show it, because I think you maby have messed up the really problem with my login script thing.... I just want to post the value of $S1three(checkstatus.php) in main.php
  8. What I'm trying to do is get the data from MySQL (in checkstatus.php), put it into $S1username, $S1three ... and then by a Session get it to main.php and show it over there.. The only thing I get from connect.config.php is the value $host, $username, $password... for connecting to MySQL BTW: You quoted from wrong message, look at reply #10 And thank you all for helping me, sorry if I dont understand most of it =)
  9. Ok? I read the text in the link, understood almost everything in it. But I still dont know how to continue
  10. this one is also incorrect if(isset($_SESSION['LoginS1'])) { check single quotes Does not still work. Maby the problem is that when you login with the correct username and password this happens: $_SESSION['LoginS1'] = true; Maby I shall insted og making it true, register it?
  11. ok, but thats not the real problem here. Check out the $_SESSION['ThreeS1'] insted BTW: I tryed if(isset($_SESSION['LoginS1])) { But I get the message "Access denied!"
×
×
  • 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.