Jump to content

0xMatt

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by 0xMatt

  1. You would need to modify your code before doing anything else. Currently, what your script does is it allows a user to login, once a successful login attempt is performed a session is created with array key login and value 1 So now we can see if that user is logged in but we can't find out any information about them? This is because no actual user data is stored in the session, just an understanding that the user successfully logged in. Some may say, oh well we can just set the value for login to correspond to the users id. You can do this as well. My method is flawed because I'm using your query that checks if the username and password matches the $_POST data to store user information. I won't go into more detail about this unless you specifically ask. You'll want something like this: <?phpif ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $query_rows = mysql_num_rows($query); if($query_rows > 0) { $user_data = mysql_fetch_assoc($query); echo ("Succesfull Login!"); session_start(); $_SESSION['user'] = $user_data; } else { echo ("Username and/or password incorrect"); }}if(isset($_SESSION['user'])){ echo "Welcome {$_SESSION['user']['username']}";} Now, let's understand how to use the new array. Say you have some extra fields in your users table, like email or location for example and you want to access it. How would you do it with this code? Simple: echo $_SESSION['user']['email']; I am a bit sleepy so I'm going to stop here. Sorry for the lack of detail within this last bit, I've grown quite tired of posting this and I'm dozing off. Ask any questions you want and I'll get to them once my mind has straightened up.
  2. Also, isAlive is not a function, so once you fix your first issue you'll immediately run into another. You should definitely try learning some php a bit more before you take dip into the objects pond. This is what you want though I have no idea why: <?php class Person { public $isAlive = true; public $firstname ; public $lastname ; public $age; } $teacher = new Person; $student = new Person; echo $teacher->isAlive; // prints 1 ?>
  3. Not only should you have used the opposite functions but you should have called them oppositely as well. <?php $array = array('one','two','three'); $compressed = base64_encode( gzcompress( serialize($array) ) ); $uncompressed = unserialize( gzuncompress( base64_decode($compressed) ) ); print_r($uncompressed); // prints Array ( [0] => one [1] => two [2] => three
  4. Wouldn't using the GROUP clause for the mysql query be better than building a bunch of extra php code? Mysql could handle that much faster with less code. Edit: My bad, group wouldn't be the best case, but this should be achievable with mysql. I'll look for a simple solution.
  5. You should tell us what is wrong. Are you getting a php error? No, because I used your script on my localhost and sent the email to myself which works. Have you checked your mail logs for errors? Do you have sendmail configured properly?
  6. It looks like you've already posted a topic about this issue. You may want to reconsider your approach to this entire situation. However, to answer your question, you can suppress warnings generated by a function by placing this @ symbol in front of it, e.g: @session_start(); You can also handle this by modifying your error reporting levels. In the long run, this is never the best practice. Just suppressing errors because of a poor design concept isn't recommended, ever.
  7. The issue is with the array stored in your $data variable. This code: $array = array( 'value1' => 'val', 'data' => array('name','email') ); print_r(json_encode($array)); Outputs: {"value1":"val","data":["name","email"]}
  8. If you post what's going on then we'll be glad to help. Have you checked your mail logs for errors? If you are on linux it should be in /var/log/messages or /var/log/maillog. Not sure about windows though. If it's a PHP error go ahead and post that. If you think the script is being executed but mail is just not being sent without an error make sure the mail function is indeed being executed and check the logs for errors.
  9. kicken is saying that you need to change this: while($row = mysql_fetch_array($result)) to this: while($row = mysqli_fetch_array($result))
  10. Is this the full amount of code? What defines the variable $email? In case you don't know what I'm asking, where do you have: $email = code; ? It seems that is the only missing part of code I would need, but before we get into that let's change the subject really quick. Do you understand you are using short tags? This means declaring php code by using <? instead of <?php. So you should be starting the file with <?php Also, please try to be very specific when asking for help. It would be very helpful if you provided the error message you are getting if any and how it does not work.
×
×
  • 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.