Jump to content

bogdaniel

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by bogdaniel

  1. hello i'm having a problem with a wrapper for mysql_query please cand someone help me ? var $is_connected; // the var for mysql_connect public static function query($sql) { line 33: $this->query = mysql_query($sql, $this->is_connected); if (!$this->query) { echo "error"; } return $this->query($sql); } And the error i'm having Fatal error: Using $this when not in object context in classes\mysql.class.php on line 33 i can't figure it out how should i do
  2. hello can someone explain me how does a php scraper script works ? and how can i scrap a page with live scores from soccer.. ?
  3. it's nice i like it on my table i didn't had an active option and i've didn't add for the moment details about the user only username password registration date and i've made some changes about what i had changed vchar to char on password field.
  4. hello it's not dificult i just wanted onther opinion to see how others did .. maybe someone did something more better.
  5. hello after i played a while with php doing diferent things.. i would like to start building a members system from scratch can someone provide me an example of a mysql table for this kind of script.
  6. What is your opinion for a php framework ? To use the mysqli class from php or to build one from scratch ?
  7. thank you very much for your replys now i have an ideea how should i do and stuff like that and that java ideea just get me a crazy ideea ) thanks again Bogdan.
  8. hello.. i need a small help from you guys.. and i'm trying to make a function for form validating and i'm stuck on form errors i've got no clue and no ideea how should i do that that part if user is incorect to show me next to that field an error or if password is incorect to show me next to password field an other erorr please can you help me ? thanks alot
  9. hello please can someone help me with this code.. it doesn't give any error it doesn't says something on var_dump says NULL NULL... <? function formular($stare = 1) { if ($stare == 1) { $x = ''; $y = ''; } else { $x = $_POST['x']; $y = $_POST['y']; } $formular = '<table width="100%" border="0" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="' . $_SERVER['PHP_SELF'] . '"> </td> </tr> <tr> <td><input name="x" type="text" value="' . $x . '" maxlength="3"> </td> </tr> <tr> <td><input name="y" type="text" value="' . $y . '" maxlength="3"> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Rezerva"> </td> </tr>'; return $formular; } if (!isset($_POST['x'])) { echo formular(1); } else { $x = $_POST['x']; $y = $_POST['y']; $verificare = 0; if (empty($x)) { $verificare = 1; echo '<br>Nu A fost Specificat coordonatul X.'; } if (strlen($x) < 1) { $verificare = 1; echo '<br>Minim 2 caractere.'; } elseif (!eregi('[0-9]{1}', $x)) { $verificare = 1; echo '<br>Coordonatul trebuie sa contima minim 2 caractere.'; } if (empty($y)) { $verificare = 1; echo '<br>Nu A fost Specificat coordonatul X.'; } if (strlen($y) < 1) { $verificare = 1; echo '<br>Minim 2 caractere.'; } elseif (!eregi('[0-9]{1}', $y)) { $verificare = 1; echo '<br>Coordonatul trebuie sa contima minim 2 caractere.'; } if ($verificare == 1) { echo formular(0); } else { $userid = $_SESSION['id']; $result = mysql_query("SELECT DISTINCT x, y FROM ".TBL_REZERVARI." WHERE x = '$x' AND y = '$y' "); if (mysql_numrows($result) >= 1) { exit(); } else { $sql = mysql_query("INSERT INTO ".TBL_REZERVARI." (`user_id`, `x`, `y`, `data`, `expira`, `time`) VALUES ('$userid', '$x', '$x', NOW(), CURDATE() + INTERVAL 3 DAY, CURTIME())") or die('Nu am putut adauga nimic. ' . mysql_error()); //var_dump($_SESSION); $q = mysql_query("SELECT * FROM ".TBL_REZERVARI.""); $num_rows = mysql_num_rows($q); echo "$num_rows Rows\n"; } } } ?>
  10. it almost working showing user not found
  11. hmmm i made a var dump on $username, $password, and they are showing null null even after is press the submit button :-?
  12. i've made the changes and still nothing no error nothing after trying to login it shows the login form this is my actual code after i've made the changes. <?php // Flush the buffered output. ob_start(); session_start(); require('config/dba.inc.php'); if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) { if (!get_magic_quotes_gpc()) { $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = mysql_real_escape_string(stripslashes(md5($_POST['password']))); } $sql = mysql_query("SELECT * FROM members WHERE username ='" .$username . "'") or die(mysql_error()); if (mysql_numrows($sql) == 1) { $set = mysql_fetch_array($sql); if ($password == $set['password']) { $_SESSION['username'] = $set['username']; $_SESSION['id'] = $set['id']; $_SESSION['usrlvl'] = $set['usrlvl']; $_SESSION['logged_in'] = 1; } } } if ($_SESSION['logged_in'] == 1) { echo 'welcome'; } else { ?> <div id="login"> <div class="content"> <form id="form1" method="POST" name="login" action="<? $_SERVER['PHP_SELF'] ?>"> <fieldset> <legend>Sign-In</legend> <label for="inputtext1">Client ID:</label> <input type="text" id= "username" name="username"/> <label for="inputtext2">Password:</label> <input type="password" id="password" name="password" /> <input type="submit" name="login" value="Log In" /><br /> </fieldset> </form> </div> </div> <?php } ?> <? // Flush the buffered output. ob_flush(); ?>
  13. so this should be the new code: <? if($logged_in == 1) { echo 'welcome'; } else { ?> <div id="login"> <div class="content"> <form id="form1" method="POST" name="login" action="<? $_SERVER['PHP_SELF'] ?>"> <fieldset> <legend>Sign-In</legend> <label for="inputtext1">Client ID:</label> <input type="text" id= "username" name="username"/> <label for="inputtext2">Password:</label> <input type="password" id="password" name="password" /> <input type="submit" name="login" value="Log In" /><br /> </fieldset> </form> </div> </div> <?php if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) { $logged_in = 0; return; } else { if (!get_magic_quotes_gpc()) { $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = mysql_real_escape_string(stripslashes(md5($_POST['password']))); } $sql = mysql_query("SELECT username, password FROM members WHERE username ='" . $username . "'") or die(tmp_mysql_error()); if (mysql_numrows($sql) == 1) { $set = mysql_fetch_array($sql); if ($password == $set['password']) { $_SESSION['username'] = $set['username']; $_SESSION['id'] = $set['id']; $_SESSION['usrlvl'] = $set['usrlvl']; } } } } ?> other mistakes... ?
  14. hello i got some php code that doesn't work how it should and i don't know why where did i made the mistake or what should i do :-? the should check if the data from the form is corect and if it is corect set the session and var logged_in as true please can you help me ? if($logged_in == 1) { echo 'lol'; } else { echo '<div id="login"> <div class="content"> <form id="form1" method="POST" name="login" action="' . $_SERVER['PHP_SELF'] . '"> <fieldset> <legend>Sign-In</legend> <label for="inputtext1">Client ID:</label> <input id="inputtext1" type="text" id= "username" name="username" value="" /> <label for="inputtext2">Password:</label> <input id="inputtext2" type="password" id="password" name="password" value="" /> <input id="inputsubmit1" type="submit" name="login" value="Log In" /><br /> </fieldset> </form> </div> </div>'; if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) { $logged_in = 0; return; } else { if (!get_magic_quotes_gpc()) { $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = mysql_real_escape_string(stripslashes(md5($_POST['password']))); } $sql = mysql_query("SELECT username, password FROM members WHERE username ='" . $username . "'") or die(tmp_mysql_error()); if (mysql_numrows($sql) == 1) { $set = mysql_fetch_array($sql); if ($password == $set['password']) { $_SESSION['username'] = $set['username']; $_SESSION['id'] = $set['id']; $_SESSION['usrlvl'] = $set['usrlvl']; } } } }
  15. i dont't have any error but i'm not sure what should i do next..
  16. hi people i'm trying to do a user system by my own from scratch i've started with making the function that checks the user and password in the db can you please look a little on it and see if it's ok and what should i add from now on .. what should i set inside of this function. please. function confirm($username, $password, $id) { if (!get_magic_quotes_gpc()) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); } $sql = "SELECT * FROM `members` WHERE username = '$username' AND password = '$password'"; $result = mysql_query($sql); if (!$result || (mysql_numrows($result) < 1)) { return 1; // Username Failure } $dbarray = mysql_fetch_array($result); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); if ($username == $dbarray['username']) { return; // Success! Username confirmed } else { return 2; // Indicates username failure } if ($password == $dbarray['password']) { return 0; //Success! Username and password confirmed } else { return 2; //Indicates password failure } }
  17. hello can someone help me with this code please ? it gives this errors :-s Notice: Undefined index: logged in C:\webserver\sandbox.dev\public_html\triburile\home.php on line 2 Notice: Undefined index: username in C:\webserver\sandbox.dev\public_html\triburile\home.php on line 19 Notice: Undefined index: password in C:\webserver\sandbox.dev\public_html\triburile\home.php on line 20 Unknown column 'username' in 'where clause' <?php if ($_SESSION['logged'] == 1) { echo '<div id="login">'; echo '<div class="content">'; echo '<form id="form1" method=\"POST\" action=\"login.php\">'; echo '<fieldset>'; echo '<legend>Sign-In</legend>'; echo '<label for="inputtext1">Client ID:</label>'; echo '<input id="inputtext1" type=\"text\" name=\"username\" value="username" />'; echo '<label for="inputtext2">Password:</label>'; echo '<input id="inputtext2" type=\"password\" name=\"password\" value="password" />'; echo '<input id="inputsubmit1" type="submit" name=\"inputsubmit1\" value="Go Baby" /><br />'; echo '<br /><br /><p> <a href="#">Forgot your password?</a></p>'; echo '</fieldset>'; echo '</form>'; echo '</div>'; echo '</div>'; } else { $username = form($_POST['username']); $password = md5($_POST['password']); // Encrypts the password. $q = mysql_query("SELECT * FROM `users` WHERE username = '$username' AND password = '$password'") or die(mysql_error()); // mySQL query $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r == 1) { // There is something in the db. The username/password match up. $_SESSION['logged'] = 1; // Sets the session. header("Location: index.php"); // Goes to main page. exit(); // Stops the rest of the script. } else { // Invalid username/password. exit("Incorrect username/password!"); // Stops the script with an error message. } } ?> This is the table: CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(11) NOT NULL auto_increment, `username` varchar(225) NOT NULL default '', `password` varchar(225) NOT NULL default '', `email` varchar(225) NOT NULL default '', PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  18. thank you very much for you help.. i knew it was something with INTERVAL but didn't know how to use it .. thanks again
×
×
  • 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.